Type Mismatch on Opening table

E

Erik

I am having trouble opening a table and an receiving
a "Run Time Error 13" Type Mismatch error.

The error occurs with the this line of code:

Set rstRaceData = dbs.OpenRecordset("RaceData",
dbOpenDynaset)

I can make it to the Test 1 msgbox but not the Test 2

I will accept any and all help.

The full code is as follows:

Private Sub Test_Click()
'On Error GoTo Err_Test_Click

Dim rst As Recordset
Dim rstRaceData As Recordset
Dim Win As Currency
Dim WinPay As Currency
Dim dbs As Database

Set dbs = CurrentDb

MsgBox ("Test 1")

Set rstRaceData = dbs.OpenRecordset("RaceData",
dbOpenDynaset)

rstData.MoveFirst

MsgBox ("Test 2")

WinPay = !Win

MsgBox ("Test Data Retrieved " & WinPay)

Exit_Test_Click:
Exit Sub

Err_Test_Click:
MsgBox Err.Description
Resume Exit_Test_Click

End Sub
 
G

Gerald Stanley

I would recommend that you fully qualify the dimension
statement for the recordsets i.e.
Dim rst As DAO.Recordset
Dim rstRaceData As DAO.Recordset

Hope This Helps
Gerald Stanley MCSD
 
V

Van T. Dinh

You probably use A2K0 or later and DAO Library is not included by default or
or you have included the ADO Library without differentiating the Recordset
in the declaration (both DAO and ADO have Recordset Object).

Maksure the include the DAO Library in the References and disambiguate the
declation with:

Dim rst As DAO.Recordset
Dim rstRaceData As DAO.Recordset
 
E

Erik

Thank you so much. Table is open and I can now proceed
until more questions arise. Keep up the good work please!
 
E

Erik

Thanks,

The DAO reference solved the problem. Your time and help
are appreciated and Please keep up the good work so that
more of us can learn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top