Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch on db.OpenRecordSet Query 1

Status
Not open for further replies.

rmtiptoes

IS-IT--Management
Mar 30, 2004
55
US
Hi,

Can anyone tell me why I have the following error on the "Select Statement" code when I open my form?:

Type Mismatch


Here is the code:

Private Sub Form_Load()
Dim dbname As String
Dim db As Database
Dim rs As Recordset

' Open the database.
dbname = "C:\Documents and Settings\Renee McCown\My Documents\Mylan\Equipment Application\Mylan NODBMenu"
If Right$(dbname, 1) <> "\" Then dbname = dbname & "\"
dbname = dbname & "Mylan_NODBMenus.mdb"

Set db = OpenDatabase(dbname)
Set rs = db.OpenRecordset("SELECT AssetsDrop.[PONumber] FROM AssetsDrop ORDER BY AssetsDrop.[PONumber]", dbOpenSnapshot)





Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
Two things:
1 - ensure you have a reference to Microsoft DAO <version> Object Library (in VBE - Tools | References)
2 - explicitly declare any DAO objects

[tt]Dim db As dao.Database
Dim rs As dao.Recordset[/tt]

Roy-Vidar
 
That did it! Thanks a million Roy!

Homer: But every time I learn something new, it pushes out something old! Remember that time I took a home wine-making course and forgot how to drive?
Marge Simpson: That's because you were drunk!
Homer: And how.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top