DoCmd.OpenReport

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a report rptIncidents based on a query
(qryIncidentRpt) which joins two tables -tblIncident and
tblInjury (note all Incidents have a related Injury). The
report works fine by itself.

I want to set up a form to make choices via combo boxes as
to what data is reported ie for a particular date

If I use

DoCmd.OpenReport stDocName, acViewPreview, , "Date = " &
txtDateStart

It seems like I am comparing strings. If I use = the
report contains no data
If I use < the report contains no data. If I use > the
report contains all the data

txtDateStart is an unbound field formatted as short date
eg entry I'm testing with 01-01-04

Thanks again for the invaluable assistance given here
Gail
 
I have a report rptIncidents based on a query
(qryIncidentRpt) which joins two tables -tblIncident and
tblInjury (note all Incidents have a related Injury). The
report works fine by itself.

I want to set up a form to make choices via combo boxes as
to what data is reported ie for a particular date

If I use

DoCmd.OpenReport stDocName, acViewPreview, , "Date = " &
txtDateStart

It seems like I am comparing strings. If I use = the
report contains no data
If I use < the report contains no data. If I use > the
report contains all the data

txtDateStart is an unbound field formatted as short date
eg entry I'm testing with 01-01-04


Date values need to be exclosed in # signs:

. . ., , "Date = #" & txtDateStart & "#"

BTW, Date is the name of an Access built in function.
Sooner or later, you and/or Access is going to be confused
about which one you mean. You should change the name of the
field to something like IncidentDate.
 
Back
Top