Results 1 to 4 of 4
  1. #1
    Kiley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jun 2016
    Posts
    28

    Query on Specific Field's Change in Timestamp

    In this scenario: I have two tables - One is the T_NBQuLog table which records all new incoming quotes. There is a relationship between this table and my T_NBQUStatus table in which users can choose if the quote is In Progress, Proposed, Not Written, or Written. I would like to record the date stamp on this one field - not the entire record - when it is updated - as there are reports i want to be able to run that depend on when this status changes.

    So i added a field to my T_NBQuLog table called NBQuStatusTimestamp and on my after update event on the Status combobox, i have the code me.NBQUStatusTimestamp = Date



    This worked and when i update this field, it updated NBQuStatusTimestamp properly, but now I am trying to build a query and am not sure how to word my nested IIF statements...

    IF the status is Proposed/In Progress - i want to see all records through current date, regardless of timestamp
    IF the status is Written/Not Written - i want to see all records where the NBQuStatusTimeStamp was updated for the current month

    I know i'm close to getting this. But i just can't seem to figure out how to word this expression. Any help is greatly appreciated. I hope i've explained everything clearly. Thanks in advance for your generosity!

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Field1: If proposed/in progress, true, false - criteria =True
    Field2: If written/not written, true, false - criteria on different line to Field1, = True
    Field3: If timestamp= current month, true, false - criteria on same line as Field2, = True

    In English - if the status is proposed or in progress then show that record, OR if the status is written/not written AND the date is current month then show that record.

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Not sure if this is what you are looking for. Will need to adjust to your exact tables/fields. That last part gets the month and year of the timestamp and month year of current date to see if a match.

    SELECT T_NBQuLog.NBQuLogID, T_NBQuLog.Quote, T_NBQUStatusID.NBQUStatus, T_NBQUStatusID.NBQuStatusTimestamp, DatePart("m",[NBQuStatusTimestamp]) & DatePart("yyyy",[NBQuStatusTimestamp]) AS cMonthYear
    FROM T_NBQuLog INNER JOIN T_NBQUStatusID ON T_NBQuLog.NBQuLogID = T_NBQUStatusID.NBQuLogID
    WHERE (((T_NBQUStatusID.NBQUStatus)="Proposed") AND ((T_NBQUStatusID.NBQuStatusTimestamp)<=Date())) OR (((T_NBQUStatusID.NBQUStatus)="Written") AND ((DatePart("m",[NBQuStatusTimestamp]) & DatePart("yyyy",[NBQuStatusTimestamp]))=DatePart("m",Date()) & DatePart("yyyy",Date())));

  4. #4
    Kiley is offline Novice
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jun 2016
    Posts
    28
    Thanks all for your help! I got it

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

Similar Threads

  1. Replies: 3
    Last Post: 11-12-2014, 05:31 PM
  2. Timestamp based on a field only
    By gaker10 in forum Access
    Replies: 13
    Last Post: 07-28-2014, 12:35 PM
  3. Change Text field to Memo Field in a Query
    By Yarbz in forum Queries
    Replies: 5
    Last Post: 06-28-2012, 05:24 PM
  4. Access Query to Check Timestamp
    By Meh in forum Access
    Replies: 1
    Last Post: 12-21-2010, 07:18 PM
  5. Replies: 11
    Last Post: 12-04-2010, 10:20 AM

Tags for this Thread

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