Search and validate for a login form

Bryan_M

New member
Local time
Today, 05:46
Joined
Nov 27, 2014
Messages
1
Hey everyone. I have a table called 'Klanten' wich contains the rows 'paswoord' and 'login' (and several rows not needed for this form)

So i'm trying to make a login form wich first checks if somthing is entered (this part of the code seems to work).


Private Sub Knop13_Click()

'Check to see if data is entered into Username

If IsNull(Me.Username) Or Me.Username = "" Then
MsgBox "gelieve een login in te voeren.", vbOKOnly, "Required Data"
Me.Username.SetFocus
Exit Sub
End If

'Check to see if data is entered into Password

If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Gelieve een paswoord in te voeren.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
'Coded in by Bryan



But from then on i seem to have some issues.. The part of the code underneath seems to only work for the first 'login' and 'paswoord' in my table called "Klanten".
-Username is the name for the field where they enter their 'login'.
-Password is the name for the field where they enter their 'paswoord'



If Username.Value <> DLookup("[login]", "Klanten", "[Username]='" & Username & "'") Then
MsgBox "Invalid Username. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If

If Password.Value <> DLookup("[wachtwoord]", "Klanten", "[Password]='" & Password & "'") Then
MsgBox "Invalid Password. Please try again.", vbOKOnly, "Invalid Entry!"
Exit Sub
End If



Then as last part i would like to goto another form called 'Mainmenu' if both the Login and the Paswoord is correctly entered in the fields Username and Password. Here i have the most issues as this doesn't seem to do anything at the moment

If Password.Value = DLookup("[wachtwoord]", "Klanten", "[Username]='" & Username & "'") And Username.Value <> DLookup("[login]", "Klanten", "[Password]='" & Password & "'") Then DoCmd.OpenForm "Mainmenu"
End Sub

I'm sorry if anything is unclear as i'm pretty new to this. Thanks in advance for any help!
 
the rows 'paswoord' and 'login'
You mean columns I think

Why do you have DLookups for seperate username and password, means I can use your username and my password and get access, dont think you want that!

As to why your form isnt opening, I can take a stab at that as well....
Code:
If Password.Value = DLookup("[wachtwoord]", "Klanten", "[Username]='" & Username & "'") And Username.Value [U][B][COLOR="Red"]<>[/COLOR][/B][/U] DLookup("[login]", "Klanten", "[Password]='" & Password & "'") Then DoCmd.OpenForm "Mainmenu"
Dont think that is quite right, on top of which my earlier comment (again)

Groeten uit Amsterdam

PS, please use the code tags when you post code, see my signature for a link on "How to use code tags"
 

Users who are viewing this thread

Back
Top Bottom