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

using variables within SQL statements problem

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Hi there,

I was wondering if anyone could tell me how I use a variable for an SQL statement in a recordset component. I have a variable, StrID (Holds a number), that I want to be able to use in the statement "select * from items where id= StrID". I am using an access database and cannot get the ? parameter query to work.

Thanks in advance

Rob
 
sqlString = "SELECT * FROM database WHERE id = " & StrID & " ORDER BY id ;"
[sig][/sig]
 
The recordset DTC's have a setSQLText method that allows you to set the sql for the recordset, and a requery method to let you requery the recordset.

So maybe something like compweb posted in conjunction with:

rcs.setSQLText(sqlString)
rcs.requery()


Hope this helps [sig]<p>Crystal<br><a href=mailto:crystals@genesis.sk.ca>crystals@genesis.sk.ca</a><br><a href= > </a><br>--------------------------------------------------<br>
Experience is one thing you can't get for nothing.<br>
-Oscar Wilde<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top