这是我的代码PLS帮助
({如何显示用户名!!})
UserID始终显示而不是用户名 我认为有一个错过的代码请帮忙 这是我的总决赛 我的所有表格都已完成,但我已登录表格
Option Compare Database
Private Sub BTNCancel_Click()
Dim Ans As String
Ans = MsgBox("Do you want to cancel log-in?", vbYesNo, "Shutdown the system")
If Ans = vbYes Then
DoCmd.Quit
Else
Exit Sub
End If
End Sub
Private Sub CBOEmployee_AfterUpdate()
'After selecting user name set focus to password field
Me.TXTPassword.SetFocus
End Sub
Private Sub BTNLogin_Click()
If IsNull(Me.CBOEmployee) Or Me.CBOEmployee = "" Then
MsgBox "You must Enter a User Name.", vbOKOnly, "Required Data"
Me.CBOEmployee.SetFocus
Exit Sub
End If
If IsNull(Me.TXTPassword) Or Me.TXTPassword = "" Then
MsgBox "You must Enter a Password.", vbOKOnly, "Required Data"
Me.TXTPassword.SetFocus
Exit Sub
End If
If Me.TXTPassword.Value = DLookup("UserPassword", "tblUsers", "[UserID] =" & Me.CBOEmployee.Value) Then
UserID = Me.CBOEmployee.Value
DoCmd.Close acForm, "frmLogon"
DoCmd.OpenForm "frmStudSubject"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.TXTPassword.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "You are unauthorized to access this system...Please Contact Your System Administrator.", vbCritical, "Restricted access!"
Application.Quit
End If
End Sub
答案 0 :(得分:1)
我假设用户名应该显示在CBOEmployee中。如果它显示UserId而不是该控件的ColumnWidth属性的问题。
如果折叠,则ComboBox会在ColumnWidth列表中显示第一列的文本具有非零宽度。
通常,RowSource返回第一列中具有一些id的记录集,以及第二列中显示的文本。然后,ColumnWidth属性看起来类似于“0,1.23”。