Password to protect a tab contol using a text box.

M

mikeinohio

I would like to know how could i use a text box called "txtpwordcrtl" to
enter a password that would enable a tab control called "TabCtlPatInfo". I
dont want to controp just one tab on the control but the whole control
itself, and also how could a make a form to change the password in case an
employee is terminated?
 
K

Klatuu

Don't keep the password in the control, put it in a table.
Use the After Update event of the password control to validate the entered
password. If the correct password is entered, enable the tab control:

Private Sub txtpwordcrtl_AfterUpdate()

If IsNull(DLookup("PassWord","tblPwd", "PassWord = """ & Me.txtpwordcrtl
& _
"""")) Then
MsgBox "Incorrect Passworkd"
Else
Me.TabCtlPatInfo.Enabled = True
End If
End Sub
 
M

mikeinohio

I put in a table i alreay had set up and the code you gave me didnt not work
and i ahd to make some educated adjustments and this is the codethat i ended
up with to make all the error messages go away,

Private Sub txtpwordcrtl_AfterUpdate()
' User asked to submit password to view information

If IsNull(DLookup("PatCrtl", "tblPwds", "PatCrtl = """ &
Me.txtpwordcrtl)) Then
MsgBox "Incorrect Password"
Else
Me.TabCtlPatInfo.Enabled = True
End If
End Sub

and when i tested it i got a error message that said:

Runtime Error '3075':

Snytax error in string in query expression 'PatCrtl = "test'

did i miss something somewhere?
 
K

Klatuu

This line is incorrect:
If IsNull(DLookup("PatCrtl", "tblPwds", "PatCrtl = """ &
Me.txtpwordcrtl)) Then

Should be:
If IsNull(DLookup("PatCrtl", "tblPwds", "PatCrtl = """ &
Me.txtpwordcrtl) & """") Then

Sorry about the errors, but writing code in the message editor, that is easy
to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top