-3

这是我的代码请帮助

({如何显示用户名!!})

用户ID总是显示而不是用户名我认为有一个错过的代码请帮助这是我的决赛我所有的表格都完成了但我卡在登录表格中

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
4

1 回答 1

1

我假设用户名应该显示在 CBOEmployee 中。如果它显示的是 UserId,则说明该控件的 ColumnWidth 属性存在问题。

如果折叠,ComboBox 会显示 ColumnWidth 列表中具有非零宽度的第一列的文本。

通常,RowSource 在第一列中返回一个记录集,其中包含一些 id,在第二列中显示要显示的文本。然后,ColumnWidth 属性看起来类似于“0,1.23”。

于 2013-10-18T11:18:32.750 回答