Troubles with Acc97 and password-protected Back-end database 
Author Message
 Troubles with Acc97 and password-protected Back-end database

Hi,

I have an Acc97 application, made from two MDB's - one is front-end and
another one is back-end.

I need to make a simple security code on it, as follows: BE database should
be password-protected, and application should ask for a password at startup
(which is the same as BE password).

If password is correct, app should check linked tables from BE (and relink
them if necessary).

Also, from a menu option, users should be able to change password (which
change the BE's password too, of course).

To relink, I use the following code (I removed all non-relevant code)

myBEdb = opendatabase(mydbfilname, false, false, ";pwd=" & mypwd)
for each tb in currentdb.tabledefs
    tb.connect = UpdateConnect(tb.Connect, "DATABASE=" & mydbfilname)
    tb.refreshLink
next

UpdateConnect is a custom function which returns tb.connect updated with new
BE database name
This code works OK.

However, if later in the application I need to open BE database directly
again, using the same code:

myBEdb = opendatabase(mydbfilname, false, false, ";pwd=" & mypwd)

I get an Access error - Invalid password.

I need this, in order to be able to change database password in code (in a
sub called from Security menu)

Can anyone give me a clue why is this happening? Why first time I can open
BE database providing its pawwords, but I cannot do this in any subsequent
call?

Thank you.

Regards,
Bogdan

--
________________________________



Sat, 29 Oct 2005 03:25:06 GMT  
 Troubles with Acc97 and password-protected Back-end database


Quote:
> Hi,

> I have an Acc97 application, made from two MDB's - one is front-end
> and another one is back-end.

> I need to make a simple security code on it, as follows: BE database
> should be password-protected, and application should ask for a
> password at startup (which is the same as BE password).

> If password is correct, app should check linked tables from BE (and
> relink them if necessary).

> Also, from a menu option, users should be able to change password
> (which change the BE's password too, of course).

> To relink, I use the following code (I removed all non-relevant code)

> myBEdb = opendatabase(mydbfilname, false, false, ";pwd=" & mypwd)
> for each tb in currentdb.tabledefs
>     tb.connect = UpdateConnect(tb.Connect, "DATABASE=" & mydbfilname)
>     tb.refreshLink
> next

> UpdateConnect is a custom function which returns tb.connect updated
> with new BE database name
> This code works OK.

> However, if later in the application I need to open BE database
> directly again, using the same code:

> myBEdb = opendatabase(mydbfilname, false, false, ";pwd=" & mypwd)

> I get an Access error - Invalid password.

> I need this, in order to be able to change database password in code
> (in a sub called from Security menu)

> Can anyone give me a clue why is this happening? Why first time I can
> open BE database providing its pawwords, but I cannot do this in any
> subsequent call?

> Thank you.

> Regards,
> Bogdan

If I were you, I'd put a breakpoint on that second OpenDatabase line and
check the value of the variable [mypwd] at that point.  Maybe you've got
variable scoping problems -- do you have Option Explicit turned on
throughout your database? -- or maybe the value is being lost due to an
unhandled error or your project's being reset for some unknown reason.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)



Tue, 01 Nov 2005 10:17:24 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to open a password-protected back-end from code

2. How to open a password-protected back-end from code

3. Copy Back-end and Password

4. Saving a filter as a query in back-end database

5. Adding Fields to an attached back-end database

6. VB solution using Access back-end database

7. Backend or front end trigger in database?

8. storing nulls in back-end database

9. storing nulls in back-end database

10. A2k: Controlling a back-end MDB from its FRONT-end MDB

11. A2K Updating Back End with new fields from Front End

12. Compact the back-end data from the front-end

 

 
Powered by phpBB® Forum Software