Hi, I'm sorry about this very basic question, you will most likely think I'm stupid, but I've got a code to make a Login Screen, and I know I have to put it in Visual Basic, but I haven't a clue where it goes. So could someone tell me.
Sorry for this silly question, I have looked around a bit but cannot find anything I'm looking for.
I'm on Access 2007 by the way, not sure if that makes any difference.
Sorry for this silly question, I have looked around a bit but cannot find anything I'm looking for.
I'm on Access 2007 by the way, not sure if that makes any difference.
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 = 'leigh" & txtUsername & "' AND Password = 'help" & 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