Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Aug 2001
    Location
    Richmond, Virginia, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Range In A Report (Access 2000)

    I have a report that where I want the starting and ending dates to be determined based on user input on a form. The between statement works fine when both the starting and ending date fields have been filled out, however I would like more flexibility. What I'd like is to handle each of these scenarios:

    If the user leaves both date fields blank on the form, I'd like to show all records.
    If the user enters only the starting date, I'd like to show all records >= the starting date.
    If the user enters only the ending date, I'd like to show all records <= the ending date.
    If the user enters both a starting and ending date, show all records between those dates.

    Thanks!
    Vernon

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Range In A Report (Access 2000)

    Say that your controls are named txtStartDate and txtEndDate on a from frmSelect, and that your date field is named DateField. Use this as WhereCondition in DoCmd.OpenReport, or in the WHERE clause of a query:

    ([Forms]![frmSelect]![txtStartDate]<=[DateField] Or [Forms]![frmSelect]![txtStartDate] Is Null) AND ([Forms]![frmSelect]![txtEndDate]>=[DateField] Or [Forms]![frmSelect]![txtEndDate] Is Null)

  3. #3
    New Lounger
    Join Date
    Aug 2001
    Location
    Richmond, Virginia, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Range In A Report (Access 2000)

    That was exactly what I needed.

    Thanks!!!

    Vernon

Posting Permissions

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