Forum Home
Press F1
 
Thread ID: 67990 2006-04-13 00:48:00 VB / MS Access pico (4752) Press F1
Post ID Timestamp Content User
446040 2006-04-18 12:01:00 Hi Ross

To disable the login text box use
Me.MyLoginTextBoxName.Enabled = False

Make sure you use the actual login text box name.

To hide the form use this:
DoCmd.SelectObject acForm, "MyFormName"
Me.Visible = False

You won't need the select object line if the form still has the focus (i.e. it is optional). If it doesn't have the focus (after doing all of the other things in your script) then you will need that line. Remember to use your actual form name.

HTH, Andrew
andrew93 (249)
446041 2006-04-18 21:26:00 Hi Andrew,

That code you gave me worked great. Here is the code that I'm using. Thanks.

Private Sub EnterDatabase_Click()
On Error GoTo EnterDatabase_Click_Err

Dim Response
'This checks to see whether the password is correct
If DLookup("[Password]", "Users", "[Username] = forms!Login!Username") = Forms!Login!Password Then GoTo Login
'This is the reponse you get if your password is incorrect
Response = MsgBox("You entered an incorrect password", vbOKOnly, "Incorrect Password")
Exit Sub

Login:
'this makes the password and username fields unchangeable
Me.Username.Enabled = False
Me.Password.Enabled = False
'this makes the form invisible
Me.Visible = False
'this opens the main menu
DoCmd.OpenForm ("MainMenu")
Exit Sub

EnterDatabase_Click_Err:
MsgBox Error$
End Sub
pico (4752)
1 2