Login Screen

rsteenoven

New member
Local time
Today, 12:56
Joined
Nov 26, 2008
Messages
9
I'm making a login screen for my database in a form. It has a user name bit and a password bit.

How do I make it so the login button i made, checks whether the password and username are correct, then if they are correct, it opens the main screen. If incorrect i want a validation message that says its wrong.

do i need some sort of crappy programming junk?

cheers
 
Do a search and you will find many examples of passwords / logins etc.

Plus, I think as time goes on you will realise that using VBA is not "crappy programming junk" - it is a necessary part of any well made database.

Col
 
ColinEssex is right. VBA is perhaps the easiest way to check username/password.

Code:
Private Sub CommandButton1_Click()
     
     If IsValidUser() = True Then
          OpenNextForm
     Else
          MsgBox "Invalid Username/Password"
     End If

End Sub

Private Function IsValidUser() as Boolean

     Dim rs as Recordset
     Dim sSQL as string

     sSQL = "SELECT COUNT(*) FROM tblUser WHERE UserName = '" & txtUsername & "' AND Password = '" & txtPassword & "' "

     Set rs = db.OpenRecordset(sSQL)

     If rs(0)>0 then
          IsValidUser = True
     Else
          IsValidUser = False
     End If

     rs.close
     set rs = nothing

End Function
 

Users who are viewing this thread

Back
Top Bottom