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

Find a recordset with DAO .Need Help

Status
Not open for further replies.

DUF

Technical User
Mar 10, 2001
107
IE
Hi,
I use the following code which works ok.
Dim db as Database
Dim rs as Recordset
Dim strSql as String

strSql = "Select * From tblProducts Where ProductID = " & Me.txtproductID
set db = currendDb
set rs = db.OpenRecordset(dtrSql,dbOpenDynaset)
with rs
.edit
.
.
End with
rs.close

How can I redo strSql so where it will select a recordn that match the values of my threee txtboxs on a form
something like this

srtSql = ("Select * From tblProducts where productId = me.txtproductid And where partNo = me.txtPartNo and where Size = me.txtSize)

Can anyone help????

Duf
 
Try this:

strSQL = ("SELECT * FROM tblPRODUCTS " _
&"WHERE PRODUCTID = "& txtProductID _
&" AND PARTNO = "& txtPartNo &" AND SIZE = "& txtSize &"") ERM
 
Hi,
Thanks EnS for that it almost works I am getting a Run Timer Error '3464'
Data type Mismatch in criteria Expression

now productid as set as text and so is Size partNo is set as number

I assume it has something to do with PartNo been a different format ??

can the strsql be modified to suit this????

thanks

duf
 
Place a single quote " ' " in between the = and double quote for those data types that are text. i.e.

strSQL = ("SELECT * FROM tblPRODUCTS " _
&"WHERE PRODUCTID = ' "& txtProductID &" ' " _
&"AND PARTNO = "& txtPartNo &" AND SIZE = ' "& txtSize &" ' ")

Hope this helps ERM
 
I should also point out that you do not want to put a space in between the single quote and the double quote. I did it here just for clarity, however, if a space is there, then the where condition will look for a text value that includes a space before and after the value in which you are looking for. ERM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top