Thanks for all of your help!
Now there are no errors, but the report opens up blank if there is no dates
in the [begindate] and [enddate] and shows the data if there are dates.
Below is all of the code:
----------start of code--------------
Private Sub Preview_Click()
If IsNull([BeginDate]) And IsNull([EndDate]) Then
DoCmd.OpenReport "Specific Employee", acViewPreview
Else
If [BeginDate] > [EndDate] Then
MsgBox "Ending date must be greater than Beginning date."
DoCmd.GoToControl "BeginDate"
Else
DoCmd.OpenReport "Specific Employee", acViewPreview, ,
"[CheckInDate] Between #" & Me![BeginDate] & "# and #" & Me![EndDate] & "#"
Me.Visible = False
End If
End If
End Sub
---------end of code-----------
Douglas J. Steele said:
You still have too many quotes: there should not be one in front of Between.
"[DateField] Between #" & Me![StartDate] & "# and #" & Me![EndDate] & "#"
BTW, hopefully you realize that StartDate and EndDate must be in mm/dd/yyyy
format, regardless of what you've set the short date format to on your
machine.
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
James said:
Thank you again!
I took the one quote out and now I hav a complie error: syntax error. Here
is the current code (all on one line):
DoCmd.OpenReport "ReportName", acViewPreview, , "[DateField] "Between #" &
Me![StartDate] & "# and #" & Me![EndDate] & "#"
What's wrong and why don't I need the # around [DateField]?