• Using VBA to create a text string of records (A2k)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Using VBA to create a text string of records (A2k)

    Author
    Topic
    #421981

    I have a query whose criteria results in a list of names. What I want to do is, on a button click, create a report that will list all the names, separated by a comma, for example, if my query returned:

    NAME
    JOHN
    JOE
    BOB
    FRANK

    I would want my report to show NAME: JOHN, JOE, BOB, FRANK

    Viewing 1 reply thread
    Author
    Replies
    • #960751

      Hi Jeremy,
      I normally do that by getting a recordset and using a Do Until Loop.

      With rst
      	Do Until .EOF
      		strString = strString & [FirstName] & ", "
      	.MoveNext
      	Loop
      End With
      strString = "NAME: " & Left(strString , Len(strString ) - 2)
      

      You can then place that into a textbox (or whatever) on your report.

      gdr

    • #960755

      You can also use the Concat function attached to post 301393. You must copy that function into a module.

    Viewing 1 reply thread
    Reply To: Reply #960751 in Using VBA to create a text string of records (A2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel