DoCmd.OpenReport

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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DoCmd.OpenReport 5
DoCmd.OpenReport problem 1
Add Cases 1
Date format problem 3
OpenArgs Used in Subform 1
Help with WHERE filter on opening report from dialog 4
Printing Problem 1
Creating report on criteria 2

Top