Code errors

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having trouble with the following code, I keep getting "Type mismatch"
error at the "Set rstbd = ..." line:

Dim dbU As Database
Dim rstdb As Recordset

Set dbU = CurrentDb
Set rstdb = dbU.OpenRecordset("SELECT * FROM tblPatients;")

With rstdb
.MoveLast
.MoveFirst

If Not .EOF Then
DoCmd.GoToRecord , , acNext
End If
End With

The code is on the click event of a navigation button. I'm trying to trap
EOF to stop the user clicking into a new record on a form that displays all
records in the db.

Can anybody shed any light on where I'm going wrong, thanks

Ian
 
It is possible your recordset is Dim'd as an ADO recordset. Try use:
Dim dbU As DAO.Database
Dim rstdb As DAO.Recordset
 
Duane,

Thanks for the help, it cured my problem, I'll certainly look out for that
one in the future. The remaining code doesn't work properly but I'll figure
that one out!

Cheers,
Ian.
 
Back
Top