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

How Can I vary the select statement

Status
Not open for further replies.

peezonn

MIS
Dec 13, 2002
7
US
I am new to VB. Could someone please tell me how to vary my select statement in one Sub based on a variable passed to that sub from another sub it was called from. For example:

In the calling sub, I found that I need a UID Number on Line_segment 65-295-100A. So I call the sub that searches for the UID called GETUID. In it I pass 2 variables. The Line_Segment name (65-295-100A) And a blank variable UID, both as strings. In the Sub called GETUID I want to select just the Line_segment 65-295-100A from my currentDB.OpenRecordSet.

My Select Statement looks like this.

Set rs = CurrentDb.OpenRecordset("select * from [STAR_LINE_SEGMENT1] where LINESEGNAME = ' & NewName & '")


The next time the I loop through my program I may want to look for a UID for a differant Line_segment.

Can you tell me what is wrong with my Set Statement?

 
Dear Peezonn
for select string variable in where statement , you
can use the following code :
Code:
Set rs = CurrentDb.OpenRecordset("select * from [STAR_LINE_SEGMENT1] where LINESEGNAME = '" & NewName   
& "'")

i hope that helps you.
brgd
 
It doesn't select the record. And the record is in the database to select.

The Current set statement does not give me an error but it will not return a record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top