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 to output multiple records returned in VBA query

Status
Not open for further replies.

jordanh

Technical User
Nov 11, 2002
47
GB
I'm using a function to populate a column in a query. I essentially need to take all the records from one table that match the primary key in another and populate the query's column with them.

This is what I have:

Code:
strsql = "big SELECT query returning three fields"

dim rst as ADODB.Recordset
set rst = CurrentProject.Connection.Execute(strsql)

Now this will return a number of records, from which I need to extract the first field of each (using rst.Fields(0).Value I presume).

My problem is that I can't work out how to cycle through the records.

Any help??? I'm totally stuck.

TIA,

Jordan

 
Have a look at the MoveNext method and the EOF property of the Recordset object.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
thanks PH, it did help.

And thanks for making me work it out myself (to some extent) :)

Code:
Do While Not rst.EOF
	output = output & ", " & rst.Fields(0).Value
	rst.MoveNext
Loop

Almost painfully simple. Thanks again.

Jord
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top