Form Password and Linked Tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Using the code found here -->
http://support.microsoft.com/default.aspx?scid=kb;en-us;209871

I created a password-protected form. Now I have two problems:
1. After I've typed in the password, I don't need to type it in again as
long as the DB stays open; but once it closes and reopens I need to type it
in. How do I make it required every time I try to open the form?

2. I also want to split the Db. However, whether I change the code from
dbOpenTable to dbOpenDynaset, I get error messages and the form opens whether
the password was entered or not.

Any help would be appreciated.
Thanks in advance!

Mike
 
Hello "Jabutron".

Jabutron said:
Using the code found here -->
http://support.microsoft.com/default.aspx?scid=kb;en-us;209871

I created a password-protected form. Now I have two problems:
1. After I've typed in the password, I don't need to type it in again
as long as the DB stays open; but once it closes and reopens I need
to type it in. How do I make it required every time I try to open the
form?
How do I make it required every time I try to open the form?

The form must be closed in order to make this work.
I guess that you just make it invisible.
2. I also want to split the Db. However, whether I change the code
from dbOpenTable to dbOpenDynaset, I get error messages and the
form opens whether the password was entered or not.

Add a line in the Error_Handler (as the first line):
Cancel = True

This will prevent the form from being opened in case of a runtime error.
To avoid that error:
The Index property and Seek method are only available when using
dbOpenTable.
Replace these two lines by the following one:
rs.FindFirst BuildCriteria("ObjectName", dbText, Me.Name)
This should work fine.
 
Thanks for the help. I got the second part working fine.

But the first question I still need help on. You state:
"The form must be closed in order to make this work. I guess that you just
make it invisible."
Make the form invisible? I'm not sure I follow. What about resetting my
variables?

Thanks!

Mike
 
Hello Jabutron.


Jabutron said:
Make the form invisible? I'm not sure I follow.
What about resetting my variables?

If your form is not closed, the Open event isn't fired again.
In order to make the password form appear again, first close your form.
Then, when you re-open it, the passsword form appears again.
 
Wolfgang (et al.):

I apologize; I wasn't being clear. Your answer fits in with what I was
asking. Thanks for that. So let me restate the problem:

When I click to open my password protected form, a password entry form
appears. After I enter the PW to get to the protected form, the PW entry
form closes, and the PW protected form opens. I do what I need to do and
close the form. I'm now back to my main form. When I click to open the
PW-protected form again, the PW entry form opens and if I hit my "Cancel"
button the PW form closes and the PW protected form opens - definitely *not*
what I want.
So I was wondering if I needed to reset a variable in my code, or if there
is different code I needed to insert. If I compact and repair I don't have
this problem.

Thanks for all your help and sorry for all the confusion.

Mike
 
Hello "Jabutron".

Jabutron said:
http://support.microsoft.com/default.aspx?scid=kb;en-us;209871
[...]
When I click to open my password protected form, a password entry
form appears. After I enter the PW to get to the protected form, the
PW entry form closes, and the PW protected form opens.
I do what I need to do and close the form. I'm now back to my main
form. When I click to open the PW-protected form again, the PW
entry form opens and if I hit my "Cancel" button the PW form closes
and the PW protected form opens - definitely *not* what I want.
So I was wondering if I needed to reset a variable in my code, or if
there is different code I needed to insert.
[...]

Now, I see the problem. Insert a line of code before DoCmd.Openform
( after the comment ' Prompt the user for the Password..):
MyPassword = ""
 
Back
Top