Type Mismatch Error

Legion

New member
Local time
Today, 10:39
Joined
Jun 4, 2004
Messages
7
Can anyone tell me where the type mismatch error is coming from?

Private Sub Form_Load()
Dim rs As Recordset
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("SELECT [Survey Number] FROM [Main Table]")
rs.MoveLast
Forms!Form_Main!RecordNumber.Value = rs(0)
rs.Close
Set dbs = Nothing
End Sub

The error is attributed to the following line....
Set rs = dbs.OpenRecordset("SELECT [Survey Number] FROM [Main Table]")

Thanks,
Legion
 
I'd be willing to bet it's because you need to explicitly specify what type of db access model you're using. Try using:

dim rs as DAO.recordset

instead of:

dim rs as recordset

Sam.
 
dsmaj said:
I'd be willing to bet it's because you need to explicitly specify what type of db access model you're using. Try using:

dim rs as DAO.recordset

instead of:

dim rs as recordset

Sam.

Now I get the error User-Defined type not defined in reference to DAO.recordset.
 
Legion said:
Now I get the error User-Defined type not defined in reference to DAO.recordset.

Make sure you have a reference set to DAO in your access project.

Sam.
 
dsmaj said:
Make sure you have a reference set to DAO in your access project.

Sam.
If by that you mean going to tools... reference and selecting DAO, I can't, reference seems to be grayed out.
 
Legion,

Get your code in Design view ... Then Tools --> References

Wayne
 

Users who are viewing this thread

Back
Top Bottom