Lee Rabbit
New Member
- Joined
- Apr 30, 2020
- Messages
- 43
- Office Version
- 2010
- Platform
- Windows
Hi All,
I have a simple login form that requires a passcode, pretty basic.
I am using specified dates to control what passcode is required to continue but I am having a bit of trouble configuring it.
I have 2 dates currently, 08/06/2020 and 09/06/2020 and I am looking for the correct passcode. However, if I enter the incorrect passcode I am getting 2 incorrect passcode msgbox's and then when I enter the correct passcode, it initially says the passcode is incorrect but then on clicking ok on the msgbox it tells me the passcode is correct and continues to destination.
Below is the code I am using. I am still learning so all help is gratefully received.
Thanks in advance.
Lee
I have a simple login form that requires a passcode, pretty basic.
I am using specified dates to control what passcode is required to continue but I am having a bit of trouble configuring it.
I have 2 dates currently, 08/06/2020 and 09/06/2020 and I am looking for the correct passcode. However, if I enter the incorrect passcode I am getting 2 incorrect passcode msgbox's and then when I enter the correct passcode, it initially says the passcode is incorrect but then on clicking ok on the msgbox it tells me the passcode is correct and continues to destination.
Below is the code I am using. I am still learning so all help is gratefully received.
VBA Code:
Private Sub InputButton_Click()
Dim toDAY As String
Dim D1, D2 As Date
Dim P1, P2 As String
Dim passcode As String
passcode = Pword.Text
toDAY = Date
D1 = DateSerial(2020, 6, 8)
D2 = DateSerial(2020, 6, 9)
P1 = "123456"
P2 = "987654"
If toDAY < D1 And passcode = P1 Then
MsgBox "Welcome Back", vbInformation
Unload Me
Else
MsgBox " PASSCODE INCORRECT, PLEASE TRY AGAIN " _
, vbCritical, "ERROR MESSAGE"
If toDAY > D1 <= D2 And passcode = P2 Then
MsgBox "Welcome Back", vbInformation
Unload Me
Else
MsgBox " PASSCODE INCORRECT, PLEASE TRY AGAIN " _
, vbCritical, "ERROR MESSAGE"
End If
End If
End Sub
Thanks in advance.
Lee