spectraflame
Well-known Member
- Joined
- Dec 18, 2002
- Messages
- 830
- Office Version
- 365
- Platform
- Windows
I am using the following code to password protect a form. However, if the user does not key anything into the password text box and clicks the OK button, the form still opens.
How do I add a statement to the code that will error out if the text box is blank?
Matthew
____
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Form1"
If Me.Text0 <> "test" Then
MsgBox "Incorrect Password!"
Exit Sub
Else
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.OpenForm FormName = "Form1"
End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub
How do I add a statement to the code that will error out if the text box is blank?
Matthew
____
Private Sub Command3_Click()
On Error GoTo Err_Command3_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Form1"
If Me.Text0 <> "test" Then
MsgBox "Incorrect Password!"
Exit Sub
Else
DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria
'DoCmd.OpenForm FormName = "Form1"
End If
Exit_Command3_Click:
Exit Sub
Err_Command3_Click:
MsgBox Err.Description
Resume Exit_Command3_Click
End Sub