I have the following code:
Private Sub cmdSubmit_Click()
If Me.txtPassword.Value = "" Then
Me.Hide
retry = MsgBox("You must enter a password first. Would you like to try again?", vbYesNo, "Retry?")
Select Case retry
Case vbYes
Me.txtPassword = ""
Me.txtPassword.SetFocus
Me.Show
Case vbNo
Unload Me
End Select
End If
If Me.txtPassword.Value = "regional" Then
Unload Me
Sheets("DATABASE").Visible = True
Sheets("DATABASE").Select
Else
Me.Hide
retry = MsgBox("The password is incorrect. Would you like to try again?", vbYesNo, "Retry?")
Select Case retry
Case vbYes
Me.txtPassword = ""
Me.txtPassword.SetFocus
Me.Show
Case vbNo
Unload Me
End Select
End If
Dim lastrow As Long
With Sheets("DATABASE")
lastrow = .Range("A2").End(xlDown).Row
.Cells(lastrow + 1, 1).Value = txtLastName.Text & ", " & txtFirstName.Text
.Cells(lastrow + 1, 2).Value = txtCCN.Text
.Cells(lastrow + 1, 3).Value = txtDateofhire.Text
.Cells(lastrow, 4).Resize(1, 6).Copy .Cells(lastrow + 1, 4)
End With
Application.CutCopyMode = False
txtFirstName = ""
txtLastName = ""
txtCCN = ""
txtDateofhire = ""
End Sub
which is to require a password prior to submitting the form. It works except if the User selects NO during the first section of code (where it says you must enter a password). I am getting an Automation error that says the Calle(Server is not available. Any ideas?
Bookmarks