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

Type Mismatch when Querying MS Access Database

Status
Not open for further replies.

saigoyume

Technical User
Jun 23, 2013
2
AU
hi guys, just started a small project and i am working with a database with a column of varchar(64). (i want to store a short string in that column)

when i try to query that column, eg

SQL = "Select Comments from table where username = '"&username&"'"

set results = objConn.Execute(SQL)

now so far thats fine, but whenever i try to do anything with the 'results' variable i get an error 'type mismatch'

vartype of 'results' return 9 as automation object.

so my question is, how do i obtain the string stored and/or is there any other way i could do this easier?

cheers
 
How is objConn open ?
Why use .Execute instead of .OpenRecordset ?
What about something like this:
MsgBox results.Fields("Comments")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ahh yep that worked thanks. I used execute because it seemed fast and someone else showed it to me... im not entirely sure about the properties of the variable once ive read it out of the database XD
 
The difference - in my experience - is that .execute returns a two-dimensional array and, when it comes to traversal, you're on your own. .openRecordSet also returns an ADO object. This is, arguably, better because an object contains context - not to mention easy property access and traversal functionality.


-Geates

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top