Password Protect a Tabbed Form HELP Please

weilerdo

Registered User.
Local time
Today, 03:45
Joined
Apr 21, 2005
Messages
109
Hey everyone, I have searched and searched but cant find the answer. I have a Form that has 6 tabs on it. I need 1 of the tabs to only be accessable to the managers to update the information. I found some code that seem to be what I needed, but I cant figure out why it is erroring.

I will attach the sample to see if anyone knows.

Basically what I need is when a manager clicks on this 1 tab it will pop up a box asking for a password, if they enter the correct password that tab become available to them.

Thanks for all your help with this

BTW the password on this sample is safety1st
 

Attachments

Hey everyone, I have searched and searched but cant find the answer. I have a Form that has 6 tabs on it. I need 1 of the tabs to only be accessable to the managers to update the information. I found some code that seem to be what I needed, but I cant figure out why it is erroring.

I will attach the sample to see if anyone knows.

Basically what I need is when a manager clicks on this 1 tab it will pop up a box asking for a password, if they enter the correct password that tab become available to them.

Thanks for all your help with this

BTW the password on this sample is safety1st

Try changing the name of your public variable from Password to something like strPassword, certain names like Password, Command, Date can be reserved words in Access.
 
I would do it a little different. I would put a button on the tab you want secured and display the controls if the password is correct. If incorrect then close the form.
 
How would you code it to hide all the controls on the page? Sorry not really up on all the VB that I should be.
 
Try changing the name of your public variable from Password to something like strPassword, certain names like Password, Command, Date can be reserved words in Access.
DJkarl, I tried that and now all I am getting is incorrect password no matter what I type in.

Here is what I changed them to.

Private Sub TabCtlClientData_Change()
Dim strPassword As String

DoCmd.Echo False
If Me!TabCtlClientData = 1 Then ' 5 being the page number you want to password protect
Me!TabCtlClientData = 0
DoCmd.OpenForm "frmPassword", , , , , acDialog
If "strPassword" = "train" Then
Me!TabCtlClientData = 1
Else
MsgBox "Incorrect Password"
End If
End If
DoCmd.Echo True
End Sub

and on the frmPassword form I am using

Private Sub txtPassword_AfterUpdate()

If Me!txtPassword = "train" Then
strPassword = "train"
Else
strPassword = ""
End If
DoCmd.Close acForm, Me.Name
End Sub
 
Private Sub TabCtlClientData_Change()
Dim strPassword As String

DoCmd.Echo False
If Me!TabCtlClientData = 1 Then ' 5 being the page number you want to password protect
Me!TabCtlClientData = 0
DoCmd.OpenForm "frmPassword", , , , , acDialog
If "strPassword" = "train" Then
Me!TabCtlClientData = 1
Else
MsgBox "Incorrect Password"
End If
End If
DoCmd.Echo True
End Sub

and on the frmPassword form I am using

Private Sub txtPassword_AfterUpdate()

If Me!txtPassword = "train" Then
strPassword = "train"
Else
strPassword = ""
End If
DoCmd.Close acForm, Me.Name
End Sub


the bold area above should not have quote marks around it. Maybe that would help if you removed them.
 
Here's your database with some slight modifications, seems to work OK for me.
 

Attachments

No good still getting incorrect password no matter what I type in
 
Thanks DJKARL, That seems to be exactly what I was looking for
 
DJkarl's one works for me. But, you will probably want to add this to the code just before or after the msgbox saying the password was incorrect:
Code:
 Me.TabCtlClientData.Pages(0).SetFocus
Otherwise you get the message box but it still goes to the restricted tab.
 

Users who are viewing this thread

Back
Top Bottom