Private Sub Command1_Click()
If IsNull(Me.txtUsername) Then
MsgBox "Please Enter Username", vbInformation, " Username Required"
Me.txtUsername.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Then
MsgBox "Please Enter Password", vbInformation, " Password Required"
Me.txtPassword.SetFocus
Exit Sub
End If
' all have values then validate it agains the table
Dim sName As String
sName = DLookup("theFieldForFullName", "Users", "Username = '" Me.txtUserName & "' And Password = '" & Me.txtPassword & "'") & ""
If sName <> "" Then
MsgBox "Welcome Back " & sName, vbInformation, "Access Allowed"
DoCmd.Close acForm, Me.Name
Else
MsgBox "Sorry .. Wrong Username or Password", vbExclamation, "Access Denied"
End If
End Sub