WB786
MIS
- Mar 14, 2002
- 610
I am getting the type mismatch error on this line: Set rs = db.OpenRecordset(SQLstr, dbReadOnly)
I am using Access 2002 and Sql 2000 - the whole code is listed below. Thanks.
Private Sub GetRecord_Click()
If Not IsNull(Me.empid) Then
Const dbReadOnly = 4
Dim db As Database
Dim rs As Recordset
Dim SQLstr As String
Dim USERID As String
USERID = Forms!frmTermEmp_IN![empid]
SQLstr = "SELECT * From tblEmployees WHERE tblEmployees.Emp_Tracker= '" & USERID & "';"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQLstr, dbReadOnly)
Do 'for every record in selection:
If rs("Emp_FirstName" <> "" Then Forms!frmTermEmp_IN![Emp_FirstName] = rs("Emp_FirstName"
If rs("Emp_LastName" <> "" Then Forms!frmTermEmp_IN![Emp_LastName] = rs("Emp_LastName"
rs.MoveNext
Loop Until rs.EOF
rs.Close
db.Close
Else
MsgBox "Please Select An Employee First", vbCritical, "Error"
End If
End Sub
I am using Access 2002 and Sql 2000 - the whole code is listed below. Thanks.
Private Sub GetRecord_Click()
If Not IsNull(Me.empid) Then
Const dbReadOnly = 4
Dim db As Database
Dim rs As Recordset
Dim SQLstr As String
Dim USERID As String
USERID = Forms!frmTermEmp_IN![empid]
SQLstr = "SELECT * From tblEmployees WHERE tblEmployees.Emp_Tracker= '" & USERID & "';"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQLstr, dbReadOnly)
Do 'for every record in selection:
If rs("Emp_FirstName" <> "" Then Forms!frmTermEmp_IN![Emp_FirstName] = rs("Emp_FirstName"
If rs("Emp_LastName" <> "" Then Forms!frmTermEmp_IN![Emp_LastName] = rs("Emp_LastName"
rs.MoveNext
Loop Until rs.EOF
rs.Close
db.Close
Else
MsgBox "Please Select An Employee First", vbCritical, "Error"
End If
End Sub