Results 1 to 3 of 3

Thread: Merge / Sort

  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    860
    Thanks
    0
    Thanked 10 Times in 9 Posts

    Merge / Sort

    I need to modify VBA code that starts a Word merge. I want to sort the data by LastName field.

    Using:

    Code:
    With ActiveDocument.MailMerge
    .Destination = wdSendToNewDocument
    With DataSource
    .QueryString ???
    End With
    .Execute
    End With
    what replaces ??? to sort the data file by LastName field?

    Thanks,
    Richard

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,514
    Thanks
    3
    Thanked 143 Times in 136 Posts
    I would try something like the following

    = "SELECT * FROM `tblNameHere` ORDER BY 'LastName'"

    If that doesn't work, I would try recording a macro to see what is captured.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    860
    Thanks
    0
    Thanked 10 Times in 9 Posts
    Thanks, Andrew. This looks good. I tried recording, and choosing sort/descending from the mailmerge recipients dialog box / refine recipients list. Nothing related to that appeared in the VBA code. What you've suggested is good for me.

    Richard

Posting Permissions

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