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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT QUERY FROM EXTERNAL DB QUESTION

Status
Not open for further replies.

ribhead

Technical User
Jun 2, 2003
384
US
I am just trying to get some data from an external Access db but keep getting a type mismatch. Can my code eventually do it or am I barking up the wrong tree?

Sub MyLook()
Dim myval As Long
Dim dbs As Database
Dim rst As New Recordset
Dim lngeto As Long
lngeto = 2 'Will be in a drop down box
Set dbs = OpenDatabase("P:\Toolroom\ToolRoom.mdb")
Set rst = dbs.OpenRecordset("SELECT Department " _
& " FROM tblorders " _
& " WHERE [ETO Number]=" & lngeto & ";")
MsgBox rst 'Test to see if it works
End Sub

Thanks

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm afraid knot.
 
Replace this:
Dim rst As New Recordset
By this:
Dim rst As DAO.Recordset
Be sure that the Micrososoft DAO 3.x Object Library is referenced.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PH still getting a type mismatch.

Any other thoughts?

Sub MyLook()
Dim myval As Long
Dim dbs As Database
Dim rst As DAO.Recordset
Dim lngeto As Long
lngeto = 2 'Will be in a drop down box
Set dbs = OpenDatabase("P:\Toolroom\ToolRoom.mdb")
Set rst = dbs.OpenRecordset("SELECT Department " _
& " FROM tblorders " _
& " WHERE [ETO Number]=" & lngeto & ";")
MsgBox rst 'Test to see if it works
End Sub

Rib

Bartender:Hey aren't you that rope I threw out an hour ago?

Rope:No, I'm afraid knot.
 
Which line?

One guess is the msgbox line, cause you cant "msgbox" a recordset.


Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top