Hey can you help me simplify this code to a for loop counter in VBA please
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWordtxt
Dim BadResult
PassWordtxt = InputBox("Please Type in password you have a maxium of 3 tries")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "The password provided was incorrect - you do not have permission"
PassWordtxt = InputBox("Please Type in password you have a 2 tries")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "The password provided was incorrect - you do not have permission"
PassWordtxt = InputBox("Please Type in password you have a 1 try")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
BadResult = MsgBox("This application will closedown due to 3 wrong entries")
Application.Quit
End If
End If
End If
End Sub
The code works fine as it is but would like it to be compact and take less load time to run.
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWordtxt
Dim BadResult
PassWordtxt = InputBox("Please Type in password you have a maxium of 3 tries")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "The password provided was incorrect - you do not have permission"
PassWordtxt = InputBox("Please Type in password you have a 2 tries")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "The password provided was incorrect - you do not have permission"
PassWordtxt = InputBox("Please Type in password you have a 1 try")
If PassWordtxt = "password" Then
stDocName = "Add/Edit frm"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
BadResult = MsgBox("This application will closedown due to 3 wrong entries")
Application.Quit
End If
End If
End If
End Sub
The code works fine as it is but would like it to be compact and take less load time to run.