Results 1 to 2 of 2
  1. #1
    hellfire104 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2016
    Posts
    1

    Help with an Access GUI formula for Update Query

    Hi there!


    I have an update query that is updating the values in a field based on an inner join. The output of which looks something like this:

    Table Name.Field = VBF Source.Date
    (THE DATE FIELD IS A TEXT FORMATTED FIELD)

    DATE
    2/1/2015
    5/1/2015
    8/1/2015
    11/1/2015
    2/1/2016

    Based on this updated field I need a formula for another update query, preferrably the same update query that does the following:

    Table Name.Field = VBF Source.CurrentPeriod
    IF VBF Source.date = MAX value (ie most recent date) then "T" ELSE "F" END IF


    Table Name.Field = VBF Source.PreviousPeriod
    If the value is exactly one year before the maxvalue then "T" else "F" END IF


    Final Result is below.


    Date CurrentPeriod PreviousPeriod
    2/1/2015 F T
    5/1/2015 F F
    8/1/2015 F F
    11/1/2015 F F
    2/1/2016 T F

    Thank you very kindly!

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    you should avoid spaces and non alpha numeric characters in table and field names and Date is a reserved word. So trying to understand this

    Table Name.Field = VBF Source.Date

    Is table called VBF and field Source.Date? or table is "VBF Source" and field called Date?

    to find the max date, use a dmax function or a subquery

    iif(mydate=dmax("myDate","myTable"),"T","F")

    or

    iif(mydate=(SELECT max myDate from myTable),"T","F")

    and combine with datediff to find the year old date

    iif(mydate=datediff("yyyy",-1,dmax("myDate","myTable")),"T","F")

    or

    iif(mydate=datediff("yyyy",-1,(SELECT max myDate from myTable)),"T","F")

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

Similar Threads

  1. Replies: 19
    Last Post: 07-13-2015, 10:15 AM
  2. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  3. Access 2007 Query formula
    By malacqua in forum Sample Databases
    Replies: 9
    Last Post: 08-11-2012, 07:20 PM
  4. Excel Formula into Access Query
    By dr4ke in forum Queries
    Replies: 7
    Last Post: 06-25-2012, 06:46 AM
  5. access query formula
    By simpleman in forum Queries
    Replies: 6
    Last Post: 11-26-2009, 09:13 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