parameter criteria

  • Thread starter Thread starter Pat
  • Start date Start date
P

Pat

I have a form that users can enter a date and it runs a
report based on the query.

I want the user to be able to either:

Enter a date range [startdate] and [enddate]
--OR--
Enter only the [startdate] to just get 1 day's data.

I know the date range I would use in the query:
Between [forms]![ShiftLog]![txtStartDate] And [forms]!
[ShiftLog]![txtEndDate]

But how do I also set up the criteria for just the 1 day?
 
Two ways:

Change the query's criteria expression to this:

Between [forms]![ShiftLog]![txtStartDate] And
IIf([forms]![ShiftLog]![txtEndDate] Is Null,
[forms]![ShiftLog]![txtStartDate], [forms]![ShiftLog]![txtEndDate])



....or....



Put code on the AfterUpdate event of the txtStartDate textbox that writes
the value of the txtStartDate textbox into the txtEndDate textbox so that
the user can either leave it or overtype it with a different value (in this
case, the query's criteria expression would not be changed):

Private Sub txtStartDate_AfterUpdate()
Me.txtEndDate.Value = Me.txtStartDate.Value
End Sub
 
Back
Top