Results 1 to 9 of 9
  1. #1
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41

    Date Range selector


    I've seen this on several web applications and was wondering if it were possible in Access. I would like to have a combo box on form that has fields for Last 7 days, Last 30 days, Last Quarter, This Quarter, and Specify dates ( where the user would select the beginning and ending dates from two different calendars). This would call info from a query and display it in a report.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What do you mean by 'fields'? Do you really mean row options?
    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.

  3. #3
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    Yes, that's what I meant...sorry

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Build a RowSource for a combo or list box by querying a table or by value list. Set RowSourceType property as ValueList. Type the list into the RowSource property:
    Last 7 days;Last 30 days;Last Quarter;This Quarter;Specify Date

    Now write code in AfterUpdate event of the combobox to do something with the selected value.
    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.

  5. #5
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    Great call. After some tweaking, I took your advice and made a "Filter" form for parameter input to display the respective reports. I created two addtional queries - one by ID and one by Name that take the parameters from form Filter and correspond to the appropriate reports.

    The only problem I am running into is where to put the date paramters. I'm not sure if this belongs in the after update property of the combo box as you suggested or the query. I have not run to parameters side by side so I'm unsure where to begin. I included the db some gist of what I'm referring to.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    I forgot about the Specify Date option.

    This could get a little complicated.

    The combobox AfterUpdate would have condition that it runs filter code only if the selection is not Specify Date, else make the date textbox visible and get focus. Then the AfterUpdate event of that textbox would have code to run filter with date parameter.
    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.

  7. #7
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    In the AfterUpdate event do I need code that supplies a date to date field in the ID or Name query or that opens the report itself. I'm not sure how to filter by name or id and date at the same time.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Here is one way to set up queries that filter records with criteria entered on form. The query would be the RecordSource for report. Instead of code to open query, use the OpenReport action, note the use of LIKE operator and wildcards. http://datapigtechnologies.com/flash...earchform.html

    I don't normally set up queries with input parameters and instead use VBA to construct the WHERE argument of OpenReport. However, you might find the parameterized query method easier for now.

    Handling the date range can be tricky. If I remember right, wildcard will not work. When date criteria is not provided, need to use alternate dates for the range that are guaranteed to be beyond any dates possibly in the db. Example:

    OrderDate BETWEEN Nz(Forms!Filter![txtStart],#1/1/1900#) AND Nz(Forms!Filter![txtEnd],#12/31/2900#)
    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.

  9. #9
    Newbie11 is offline Advanced Beginner
    Windows 2K Access 2003
    Join Date
    Dec 2011
    Posts
    41
    Thanks. This works great!

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

Similar Threads

  1. Date Range Report with Multiple Date Fields
    By StevenCV in forum Reports
    Replies: 13
    Last Post: 02-29-2012, 08:29 AM
  2. Specify A Date Range
    By jo15765 in forum Queries
    Replies: 17
    Last Post: 10-11-2011, 07:16 AM
  3. Date range Q
    By markjet in forum Queries
    Replies: 13
    Last Post: 07-18-2011, 01:00 PM
  4. Date range
    By eacollie in forum Queries
    Replies: 7
    Last Post: 06-05-2011, 03:38 PM
  5. Date range help!!
    By bananatodd in forum Access
    Replies: 26
    Last Post: 10-18-2010, 01:57 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