Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2011
    Location
    Huntsville, AL
    Posts
    4

    Unanswered: Access Query Date Variable default question

    I created a daily sales report that pulls from a query. In the query I defined in
    the Criteria field of my date [Enter Date of Sale]. Thus works great--the user can
    define any date and get a customized report.

    I would like to go one step further--if a user simply clicks OK, there is no report
    content. I would like to place the machine's date as a default, so if the user runs
    the report and gives no input the variable defaults to the current date.

    To all of the creative ones--what is the slickest way of accomplishing this?

  2. #2
    Join Date
    May 2010
    Posts
    601
    I generally avoid parameter prompts in queries because there is not way to do any validation or help the user.

    IMHO, the slickest way is to use a form to collect the criteria.

    See this example: Report Dialog Examples
    Boyd Trimmell aka HiTechCoach HiTechCoach.com (free access stuff)
    Microsoft MVP - Access Expert
    BPM/Accounting Systems/Inventory Control/CRM
    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Search the Help file for parameter queries. There is a means by which you can set a parameter query to return all values if it is not passed a parameter, and you might be able to modify this to default to the current system date.
    10% of magic is knowing something that no-one else does. The rest is misdirection.

  4. #4
    Join Date
    Mar 2011
    Location
    Huntsville, AL
    Posts
    4
    Thanks for your replies! Here is what I tried, and it is satisfactory for me--

    In the Query that the report pulls from, I amended the Criteria for the date field with this:

    IIf(IsNull([Whatevertextyouwant]),Date(),[Whatevertextyouwant])

    Exactly the result I needed...if a user clicks OK without a date, it takes him to today's info. If the user inputs a historical date and clicks OK, so be it.

    I may consider a form when the need arises to better Validate the input, but this works for the immediate goal. Thanks again!

  5. #5
    Join Date
    Sep 2006
    Location
    Surrey, UK
    Posts
    995
    Provided Answers: 2
    Glad this helped!
    10% of magic is knowing something that no-one else does. The rest is misdirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •