所以这是我用于登录系统的非常简单的代码..
每次我试着跑它,我得到; "编译错误:用户定义的类型未定义" 这是我以前从未见过的,因为访问突出了这一行" Dim rsLogin As Recordset"
无论如何都是代码的其余部分:
Private Sub Label15_Click()
Dim StaffID, Password As String
Dim Match As Integer
Dim rsLogin As Recordset
If IsNull(Me.Password) And IsNull(Me.StaffID) Then
MsgBox ("Please enter login information")
End If
If IsNull(Me.StaffID) Then
MsgBox ("Please enter a Staff ID.")
End If
If IsNull(Me.Password) Then
MsgBox ("Please enter a Password.")
End If
Match = 1
StaffID = Me.StaffID
Password = Me.Password
Set rsLogin = CurrentDb.OpenRecordset("tblStaff", dbOpenDynaset)
rsLogin.MoveFirst
Do Until rsLogin.EOF = True
If rsLogin!StaffID = StaffID And rsLogin!Password = Password Then
gblUser = rsLogin!StaffID
Match = 2
Exit Do
Else
rsLogin.MoveNext
End If
Loop
If Match = 1 Then
MsgBox ("Incorrect StaffID and/or Password.")
ElseIf Match = 2 Then
DoCmd.Close
DoCmd.OpenForm ("frmMain")
End If
End Sub
任何帮助都会很棒!
由于
答案 0 :(得分:0)
尝试使用DAO前缀:
dim rsLogin as DAO.Recordset
同时检查是否缺少参考文献。缺少引用(引用但不存在/已安装)也会导致最基本的内置函数出现编译错误。