JeroenCreemers
New Member
Dear All,
I've created a simple login form in with VBA that works fine, but i would like to add an extra verification.
Currently typing the right username and password is good enough to open the file. But what I want as extra verification is that the username also needs to equal cell C2 on sheet 2. I have given it a range name "Email". The same for the password that's also on sheet 2 but then in cell C9.
If possible I would also like add a verification that checks if the year equals the year on sheet 2 in cell C11.
Currently this is my code:
And i'm trying to get this:
I hope somebody can help me.
Kind regards,
Jeroen
MOD EDIT: Added CODE tags. Please use CODE tags to post your code.
I've created a simple login form in with VBA that works fine, but i would like to add an extra verification.
Currently typing the right username and password is good enough to open the file. But what I want as extra verification is that the username also needs to equal cell C2 on sheet 2. I have given it a range name "Email". The same for the password that's also on sheet 2 but then in cell C9.
If possible I would also like add a verification that checks if the year equals the year on sheet 2 in cell C11.
Currently this is my code:
Code:
Private Sub LoginButton_Click()
If Me.Username.Value = "admin@admin.com" Then
If Me.Password.Value = "ABCDEFGH" Then
LoginFlag = True
Unload Me
Exit Sub
End If
End If
MsgBox "Sorry, Incorrect Login Details"
End Sub
And i'm trying to get this:
Code:
Private Sub LoginButton_Click()
If Me.Username.Value = "admin@admin.com" and equals to sheet2 cell C2 Then
If Me.Password.Value = "ABCDEFGH" and equals sheet2 cell C9 Then
Year = "2018" and equals to sheet2 Cell C11
LoginFlag = True
Unload Me
Exit Sub
End If
End If
MsgBox "Sorry, Incorrect Login Details"
End Sub
I hope somebody can help me.
Kind regards,
Jeroen
MOD EDIT: Added CODE tags. Please use CODE tags to post your code.
Attachments
Last edited by a moderator: