Results 1 to 4 of 4
  1. #1
    Mattbro is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    95

    Using update query to populate tables based on a second query

    Hello All
    I have a table ‘Data’ in which I record articles that I have to send to users. I use it to monitor if they have returned said items and to generate reminder letters; The Table has fields for
    Record No (PK),
    User name,
    user address,
    user postcode,
    date sent,
    date reminder letter sent,

    In order to monitor reminder letters, I have a query QrySendLetter that captures daydatediff between Now() and date sent,
    where daydatediff>50 and ‘date reminder letter sent’ is null in addition to capturing the user details.


    I have generated a report RptReminderLetter, fed by QrySendLetter which pulls the user details off Data and thus all my letters are printed, all from a Command button on a form which opens the report.
    What I want to do is run an update query after I have printed off all my reports, that takes all the Record No’s from QrySendLetter, and populates the relative ‘date reminder letter’ sent Field in Data with a Now() value, thus the next time I run the RptReminderLetter, these items are excluded.
    I have tried various combinations with update queries, such as
    Code:
     UPDATE Data INNER JOIN [QrySendLetter] ON Data.[Record No] = [QrySendLetter].[Record No] SET Data.[1st Reminder Sent] = Now();
    …but no luck so far. Does anyone know if this is possible, and if so, how?
    Mattbro

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think the issue may be because you are using the same table "data" 2 different places.
    Do you get an error message? What exactly is the query for -suggest you show us the SQL.

    Why not put a WHERE clause on an SQL statement such as:
    UPDATE Data
    SET [date Reminder Sent] = Now()
    WHERE
    DateDiff("d", [date sent], Now) > 50 AND
    [date Reminder Sent] Is NULL

  3. #3
    Mattbro is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    95
    Aha!-Now that looks like it will work! I will try it at work and let you know. Many thanks,
    Mattbro

  4. #4
    Mattbro is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    95
    Yep -works fine. Thanks very much.
    Mattbro

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

Similar Threads

  1. Replies: 2
    Last Post: 11-27-2013, 05:24 PM
  2. Update Query based on existing date
    By axdxnco in forum Queries
    Replies: 1
    Last Post: 06-12-2013, 02:15 PM
  3. Replies: 10
    Last Post: 06-07-2012, 12:56 PM
  4. Replies: 1
    Last Post: 06-28-2011, 05:17 AM
  5. Replies: 3
    Last Post: 05-19-2010, 10:08 PM

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