Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / January 2004

Tip: Looking for answers? Try searching our database.

query filter using date from foxpro 2.6 database as data source

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pearle - 27 Jan 2004 21:55 GMT
Hi All,
I have a word 2000 mailmerge that uses a foxpro 2.6 database as th
data source.  I need to be able to query based on a date field.  When
try to enter the date the merge gives me all of the records, an
ignores the filter (ie.  foxdate equal to 01/25/2004).  I have trie
different formats for the date but none seem to work.

Any help is greatly appreciated.
Peter Jamieson - 28 Jan 2004 09:46 GMT
Unfortunately I suspect that Word does not generate SQL that the FoxPro ODBC
driver (which is where Word gets its data from) will understand. Usually,
Word 2000 will use # characters to enclose a date literal and will generate
code such as

SELECT * FROM mytable WHERE ((mydate > #01/01/2003#))

with the FoxPro driver, as you say "nothing happens" and in fact any
previous query is left in place.

Also, I don't have a simple solution. You could try
a. connecting with the dBASE ODBC driver instead, which accepts the #
syntax. (Check the "Select method" box in Open Data Source and choose e.g.
"dBASE files via ODBC". However, in my experience the "dBASE" and "FoxPro"
recognise different versions of the .dbf format and this probbly will not
work.
b. using MS Query to form your query, if it is being offered as an option
when you try to gointo Query Options. It is more complicated and you may
still have difficulties, but it should at least get the SQL right.
c. if it is just you using this merge you can try modifying the query
directly in VBA. e.g.
open up the VBA editor, go into the Immediate pane, and type
print activedocument.mailmerge.datasource.querystring
Suppse it then reports
SELECT * FROM mytable
then enter
activedocument.mailmerge.datasource.querystring = "SELECT * FROM mytable
WHERE (( mydate > { d '2003-01-01' }))

obviously altering the field names and operators to be what you need. The
date should be in YYYY-MM-DD format.
d. exporting the data to something that allows Word to do date comparisons
correctly

--
Peter Jamieson - Word MVP
Word MVP web site http://word.mvps.org/

> Hi All,
> I have a word 2000 mailmerge that uses a foxpro 2.6 database as the
[quoted text clipped - 8 lines]
>
> ------------------------------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.