Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Posts
    42

    Question Unanswered: Combining table column to a string

    Hi,

    I need some help with some code to read fields in a column and combine them into one string.

    For example, I peform a query, then want all the results in the column to be output as one string.

    Suggestions?

    Thanks.

  2. #2
    Join Date
    Nov 2002
    Location
    Belgium
    Posts
    243

    Re: Combining table column to a string

    Originally posted by ventelation
    Hi,

    I need some help with some code to read fields in a column and combine them into one string.

    For example, I peform a query, then want all the results in the column to be output as one string.

    Suggestions?

    Thanks.
    Using a recordset will solve your problem.

    Code:
    Dim rs as Recordset
    Dim strSQL as String
    Dim counter as Integer
    
    strSQL = "SELECT ..........FROM.........WHERE..........ORDER BY........."
    
    rs.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
    
    Do While Not rs.EOF
    
    For counter = 0 to rs.Fields.Count -1
       debug.print rs.Fields(counter)
    Next counter
    
    rs.MoveNext
    
    Loop
    If everything went OK the debug.print should show you all the fields of one record.

    The moveNext-statement goes to the next record of the recordset.

    Using the Fields-property gives you the possibility to concatenate in a string.
    Last edited by artemide; 04-23-03 at 10:48.

  3. #3
    Join Date
    Apr 2003
    Posts
    42

    Thumbs up Thanks.

    Thanks for the code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •