'set the variables
Dim UN As String
Dim PW As String
Dim user, pass As Boolean
'make sure none of the fields are null, or blank
UN = Text
PW = Text
If IsNull(Username) Then
MsgBox "You must enter a username."
Username.SetFocus
Else
'assign true to user
user = True
End If
If IsNull(Password) Then
MsgBox "You must enter a password."
Password.SetFocus
Else
pass = True
End If
If user = True And pass = True Then
UN = DLookup("[Username]", "LoginTable", "[Username]= '" & Me.Username & "'")
PW = DLookup("[Password]", "LoginTable", "[Password] = '" & Me.Password & "'")
End If
If Me.DummyUser = Me.Username And Me.DummyPass = Me.Password Then
MsgBox "Access granted."
Else
MsgBox "Access denied."
End If
來源
2013-06-25 12:16:23
Gik
爲什麼不使用VBA?將是最簡單的方法。 – 2011-06-01 20:30:58
我正準備參加一個考試,我必須在定時環境中創建我的系統,除了之前我沒有任何外部幫助。我見過的所有vba都很長很複雜,我只是無法記住它的心臟。如果沒有其他方法,我可以嘗試。 – 2011-06-01 21:01:40
如果您認爲VBA很長且很複雜,那麼您將會陷入麻煩,認爲您可以在不使用VBA的情況下在Access中執行此操作。 – HardCode 2011-06-01 21:23:50