Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Posts
    3

    Angry Unanswered: Automating Mail Merge using VBA

    Having some difficulties getting the Query String to work correctly.

    The date comes in as 2/5/2004
    ************************************************** ******
    qDate = Format(qDate, "mm/dd/yyyy")

    'Open the Datasource
    wrdDoc.MailMerge.OpenDataSource Name:="data.xls", _
    ConfirmConversions:=False, LinkToSource:=True, ReadOnly:=True, _
    Format:=wdOpenFormatAuto, Connection:="Data", _
    SQLStatement:="", SQLStatement1:=""

    'Set the DataSource and the Query

    theSql = "SELECT * FROM data.xls WHERE (( Date_Received = #" & qdate & "#))"

    wrdDoc.MailMerge.DataSource.QueryString = theSql
    ************************************************** *******
    It says no records are found and I know they contain records.

    Any help would be greatly appreciated!

    Thanks

    Jerami Tainter

  2. #2
    Join Date
    Jan 2004
    Location
    The Netherlands
    Posts
    421
    qDate = Format(qDate, "mmm/dd/yyyy")
    debug.pring qdate

    Try that it should show you your problem. My guess is your looking for 5 feb and the date gets interperted as 2 may.

    Regards

Posting Permissions

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