megatronixs
Registered User.
- Local time
- Today, 19:09
- Joined
- Aug 17, 2012
- Messages
- 719
Hi all,
I found some code on the web that almost does the trick I need. I only got lost in how to get all the results from a query that now comes in a few lines into one line, separated by a coma.
this is the results I get now (in the immediate window)
HK AE 18
HK CN 1
HK TR 1
HK VC 1
It would be great if I could get it like this:
HK-AE 18, HK-CN 1, HK-TR 1, HK-VC 1
This is the code I use now:
Greetings.
I found some code on the web that almost does the trick I need. I only got lost in how to get all the results from a query that now comes in a few lines into one line, separated by a coma.
this is the results I get now (in the immediate window)
HK AE 18
HK CN 1
HK TR 1
HK VC 1
It would be great if I could get it like this:
HK-AE 18, HK-CN 1, HK-TR 1, HK-VC 1
This is the code I use now:
Code:
Public Sub btn_test_Click()
Dim qry_profile_1_scr2_results As String
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("qry_profile_1_scr2_results")
' print column names
'Dim i As Integer
'For i = 0 To rs.Fields.Count - 2
' Debug.Print rs(i).Name & vbTab; 'print col names separated with a tab one from each other
'Next i
'Debug.Print rs(rs.Fields.Count - 1).Name 'last one without ; so it adds the newline
Do While Not rs.EOF
For i = 0 To rs.Fields.Count - 2
Debug.Print rs(i) & vbTab; 'print values separated with a tab one from each other
Next i
Debug.Print rs(rs.Fields.Count - 1) 'last one without ; so it adds the newline
rs.MoveNext
Loop
rs.Close 'Close the recordset
Set rs = Nothing 'Clean up
End Sub
Greetings.