Results 1 to 4 of 4
  1. #1
    daniejm is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    11

    Running multiple queries in form


    Hi all,

    I appreciate your help.

    I've got a DateRange Form built. It allows me to enter two date values and then retrieves all records on or between the defined dates. Now I'd like to accomplish a second task with this form...

    In my table I have a date of birth column ("DOB"). When running the form for Date Range, I'd also like to take the DOB column and produce an Age in an "Age" column. However, I only want it to show me the Age value for the records that are being returned by the Date Range query. Ideally: Access would find the "xdate" (dates within datee range), look at the DOB, calculate the age, then spit that out in my results. I hope this makes sense. Example:


    DATERANGEQUERY FORM
    Start Date: 1/1
    End Date: 1/3

    Returns:
    [DATE IS 1/1 TO 1/3] [CUSTOMER NAME] [AGE]


    I've tried the following expression to make the Age column populate, but it blanks out my "xdate" column AND the "age" column. Basically, adding this expression breaks my query and my form -- no errors, just no results. Here's the code I'm trying for the Age:

    Code:
    DateDiff("yyyy",[DOB],Date())+Int(Format(Date(),"mmdd")<Format([DOB],"mmdd")
    Help!

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If I counted correctly, I think you are missing a closing parenthesis

    Code:
    DateDiff("yyyy",[DOB],Date())+Int(Format(Date(),"mmdd")<Format([DOB],"mmdd"))

    If the query still doesn't work, post the SQL of the query.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    The expression you show makes no sense to me. I have tested the expression and can't get a value that is less than Format([DOB],"mmdd")

    You want to show records where DOB mmdd is between the given mmdd start and end, regardless of year?

    DOBmmdd: Format(DOB,"mmdd")

    Criteria for DOBmmdd: BETWEEN '0101' AND '0103'
    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.

  4. #4
    daniejm is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2012
    Posts
    11
    Hey all,

    Sorry for the late response. This is working now.

    Thank you for your help!

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

Similar Threads

  1. Running Queries from a form
    By HaYuM in forum Queries
    Replies: 1
    Last Post: 08-23-2013, 03:12 AM
  2. multiple queries in form
    By geraldk in forum Forms
    Replies: 5
    Last Post: 12-26-2011, 02:22 PM
  3. Replies: 11
    Last Post: 07-08-2011, 02:12 PM
  4. Replies: 13
    Last Post: 02-23-2011, 08:38 AM
  5. Running sum in queries
    By sankarkunnath in forum Queries
    Replies: 0
    Last Post: 10-24-2010, 12:26 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