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

Creating a comma delimited LOV from multiple rows into one row

Status
Not open for further replies.

Fattire

Technical User
Joined
Nov 30, 2006
Messages
127
Location
US
Trying to dynamically create a string in the WHERE clause of a SQL statement:

lets call the table 'tbl_example', column is called 'data_id'. Here's the data, 4 lines:

DATA_ID
1111
2222
3333
4444

turn this data into a string so I can assign it to a variable and plug it into a SQL statement - looking like this:
'1111','2222','3333','4444'

 
How are ya Fattire . . .

If you use an [blue]In Clause[/blue] with a subQuery/SQL, you won't have to bother concatenating. Example:
Code:
[blue]   SQL = "SELECT * " & _
         "FROM TableName " & _
         "WHERE [DataID] In (Select DataID " & _
                            "FROM TableName " & _
                            "WHERE (YourCriteria);"[/blue]
See another example in my post here: thread701-1464141

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thank you for all the suggestions...

Here's what I used eventually, works fine...

Code:
    Do While Not rec1.EOF
    varCustNum = rec1!customer_number
    varCustNumStr = varCustNumStr & varCustNum & ", "
    rec1.MoveNext
    Loop

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top