I'm sorry to keep bugging everyone, but now that I have the basic design of my database, I want to keep making it better.
I found some code on another site to make a form that you enter a password into to either open a new form (if correct) or return an error message (if not correct). I am having problems with it. I apologize to those of you who are reading the other site too. I just want to ensure I get an answer.
Here is my code for the form:
Option Compare Database
Option Explicit
Private Sub Cancel_Click()
DoCmd.RunMacro "mcrSwitchboard.OpenSwitch"
End Sub
Private Sub Form_Timer()
'If the Login screen is open for more than 30 seconds, open the switchboard.
DoCmd.RunMacro "mcrSwitchboard.OpenSwitch"
End Sub
Private Sub OK_Click()
If Me.txtPassword = "123" Then
DoCmd.RunMacro "mcrSwitchboard.OpenAdmin2"
Else
MsgBox "The password you entered is incorrect. Please try again or select cancel to return to the switchboard"
DoCmd.close Me
End If
End Sub
The form returns a compile error (ambiguous name) whether I put in the correct password or not. The only two things that work are the cancel button which takes me back to the switchboard and the 30 second default timer which also takes me back to the switchboard.
When I attach the macro OpenAdmin2 to the OK button itself "on click" it works fine. It's just the password thing that it's not dealing with.
Does anyone have any suggestions to what I'm doing wrong??
Thanks!
J.McCaul
I found some code on another site to make a form that you enter a password into to either open a new form (if correct) or return an error message (if not correct). I am having problems with it. I apologize to those of you who are reading the other site too. I just want to ensure I get an answer.
Here is my code for the form:
Option Compare Database
Option Explicit
Private Sub Cancel_Click()
DoCmd.RunMacro "mcrSwitchboard.OpenSwitch"
End Sub
Private Sub Form_Timer()
'If the Login screen is open for more than 30 seconds, open the switchboard.
DoCmd.RunMacro "mcrSwitchboard.OpenSwitch"
End Sub
Private Sub OK_Click()
If Me.txtPassword = "123" Then
DoCmd.RunMacro "mcrSwitchboard.OpenAdmin2"
Else
MsgBox "The password you entered is incorrect. Please try again or select cancel to return to the switchboard"
DoCmd.close Me
End If
End Sub
The form returns a compile error (ambiguous name) whether I put in the correct password or not. The only two things that work are the cancel button which takes me back to the switchboard and the 30 second default timer which also takes me back to the switchboard.
When I attach the macro OpenAdmin2 to the OK button itself "on click" it works fine. It's just the password thing that it's not dealing with.
Does anyone have any suggestions to what I'm doing wrong??
Thanks!
J.McCaul