Results 1 to 8 of 8
  1. #1
    wackywoo105 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    34

    Word recipient list empty with Access query.

    I have a query in Access and a word document that opens up the query. Currently the query contains every record in the database. If I alter the query in Access to select a certain set of records (based on dates) when Word opens the recipient list is empty. Checking for errors it says there were no records or no data records matched query options.



    How can I get Word to open and use the modified query?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The query works correctly in Access? Word is linking to the query? Is this mail merge?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    wackywoo105 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    34
    I should have been quicker to search for an answer. It seem replacing "*" for "%" in the query solves the issue.

    Mods please delete if you feel the need.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Thanks for sharing the solution. We will leave, might help someone else.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    wackywoo105 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    34
    In that case just to add a bit more info:

    I build the query with SQL in VBA. Using wilcards "*" works fine in access but then word reports no data. Using "%" instead of "*" shows no records in access but when word loads the query all the records are there.

    I have just created 2 versions of the query. One I can open in access and the other is the one word links to. Both work fine in their respective programs.

    E.g. ok with access but word shows no records

    SELECT Patients.Title FROM Patients WHERE Patients.[Due Date] Like "*/06/*" ORDER BY Patients.[Due Date];

    And this is ok with word but access shows no records

    SELECT Patients.Title FROM Patients WHERE Patients.[Due Date] Like "%/06/%" ORDER BY Patients.[Due Date];

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Is that day 06?

    Is [Date Due] a date/time data type?

    An alternative could be:

    SELECT Title FROM Patients WHERE DatePart("d",[Due Date]) = 6 ORDER BY [Due Date];

    I do wonder why not limiting records to current month and/or year.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    wackywoo105 is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2014
    Posts
    34
    The code is just a trimmed down snippet to show what the problem was, the actual SQL statement is very long and selects multiple dates (and has lots of chr(34) and variables in it as it's in VBA). I don't know where The Great Land is but where I am that selects all days and years for month 6.

    I'm a bit of a novice at this an don't write optimised code but it does the job bar the odd hiccup.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Viewing the date as mm/dd/yyyy structure and considering the wildcards of the date parameter, it looks like you want all months and years for day 6 - which is why I used "d" in the DatePart function.

    Just wanted to show that should probably be able to structure the SQL so don't need two versions.

    Why the need for Chr(34)? I use apostrophe to delimit text parameters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query to list only records containing a word
    By esh112288 in forum Queries
    Replies: 4
    Last Post: 11-01-2012, 05:24 PM
  2. Replies: 2
    Last Post: 02-09-2012, 04:31 AM
  3. Mailmerge: Making a list - Access to word
    By Ribido in forum Access
    Replies: 3
    Last Post: 01-07-2012, 12:40 PM
  4. Import a list of names from Word to access
    By WickedGoodOutdoors in forum Import/Export Data
    Replies: 3
    Last Post: 01-04-2011, 05:25 PM
  5. Replies: 2
    Last Post: 02-04-2010, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums