访问VBA不会让我定义一个记录集
问题描述:
所以这里是我的一个非常简单的登录系统代码..访问VBA不会让我定义一个记录集
每次我尝试运行它,我都会得到; “编译错误:用户定义类型未定义” 这是我从来没有为访问凸显了线“昏暗rsLogin作为记录”
见过反正继承人的其余代码:
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
任何帮助将是伟大的!
感谢与DAO
你在哪里定义'Recordset'? – APerson 2014-10-01 13:11:09
访问版本? ADO或DAO? – GSerg 2014-10-01 13:12:35
结果由CurrentDb分配,因此它期望一个DAO记录集。 – Barry 2014-10-01 13:13:42