我創建了一個Microsoft Access 2007數據庫。這是創建兩種形式。 1.僱員形式。 表名「tbl employee」:ID,IC NO,姓名,辦公室分支。 2.login形式。 : 表名「tble User」:UID,用戶名,密碼,啓用,全名。Access 2007 - 獲取VB用戶登錄並記錄最後修改後的表單
像往常一樣,當我登錄的用戶名(使用組合框)和密碼(使用文本框)登錄表單正常工作,因爲我使用VB,如下圖所示: -
Private Sub cbo_User_AfterUpdate()
Me.txt_Password = Empty
Me.txt_Password.Enabled = True
Me.txt_Password.SetFocus
End Sub
Private Sub cmd_OK_Click()
'test the stored password is = to the manually entered password
If Me.cbo_User.Column(2) = Me.txt_Password Then
DoCmd.OpenForm "fm_employee", acNormal
DoCmd.Close acForm, "frm_Login"
DoCmd.Close acForm, "fm_switchboard"
Else 'wrong match
MsgBox "Wrong password entered." & _
vbCrLf & "Please re-enter password.", _
vbExclamation, "Invalid Password"
Me.txt_Password.SetFocus 'places the cursor in password control
End If
'If User Enters incorrect password 3 times database will shutdown
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You do not have access to this database.Please contact admin.", _
vbCritical, "Restricted Access!"
Application.Quit
End If
End Sub
現在,我需要幫助如何在用戶客戶端修改並保存員工表單中的每條記錄後,從登錄表單中獲取全名或用戶名並記錄到該字段中。
注:登錄用戶超過1
如果您可以在您的問題中縮進代碼,這將更容易閱讀。縮進4個空格,並保存格式。 – 2011-03-11 02:17:36
這是在Access中的VBA編碼嗎?如果是這樣,那麼'Me.txt_Password = Empty'這行不能正確,因爲'Empty'應該是'Null'。我也質疑你在這裏做什麼 - 這是虛假的安全,並沒有真正做任何事情來保護你的數據。如果您正在使用它來控制程序流,那麼使用Windows登錄名稱可能會更好,因爲您不再需要擔心密碼。 – 2011-03-12 00:51:36