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

Very Simple Query. Please Help 1

Status
Not open for further replies.

Watermelon

Programmer
Apr 16, 2001
68
US
I'm very new to Access and I'm trying to write a very simple query that will run the select that I have below and put it into a recordset but everytime I run it I get a datatype error. The datatype is text in the database and it's a string on my form. Does anyone know why I would have this problem?
Thanks for any help,
TM

Dim db As Database
Dim rst As Recordset

Set db = CurrentDb

Set rst = db.OpenRecordset("SELECT * FROM Part WHERE [ReplacementParts] = '" & Forms!ReplacedPartsForm!PartEntered & "'")
The "PartEntered" field above refers to a control I have on my form.
 
The code looks ok to me. If you're using Access 2000, have you set a reference to the DAO 3.6 Object Library? If not, the type Recordset is an ADO recordset, which isn't compatible with a DAO recordset.

If you use both DAO and ADO in your database, use DAO.Database and DAO.Recordset to ensure you're getting the right ones. If you don't use ADO, uncheck it under Tools>References.

If that's not it, what error number are you getting? Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top