If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Automating Mail Merge using VBA

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-04-04, 12:24
tainter tainter is offline
Registered User
 
Join Date: Feb 2004
Posts: 3
Angry 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
Reply With Quote
  #2 (permalink)  
Old 02-05-04, 01:55
namliam namliam is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On