Hong said:
Hello, I created a report by chart wizard. and
the chart is good. And I also created a form for
enter date range: "BeginningDate" and
"EndingDate". But when I set the event in report
property it doesnt' work. It doesn't open the form
for me to enter the date range.
If I delete the event, it opens the "Enter parameter
value", and I can enter the date range, but I can't
put the text on the report header?
(1) Generally, I open the Report from a Command Button on the Form, after
the user enters the values for the criteria, using a DoCmd.OpenReport
statement. I do not Open the Form from the Report. It _can_ be done in the
manner you describe, but I find the other approach much easier and more
convenient.
(2) If it is asking for a parameter, then you are using a parameter query.
Using a parameter query from code doesn't always work the way you expect.
Thus, I use a Query that has no Criteria, and supply the Criteria in the
WhereCondition argument of the DoCmd.OpenReport that is in the VBA code that
runs in the Click event of the Command Button described in (1), above.
(3) An alternative, with the latest few releases of Access is that you pass
a WHERE clause in the OpenArgs argument of the DoCmd.OpenReport, then
retrieve that, concatenate it with the base Query to replace the
RecordSource in the Report's Open event. (In earlier releases of Access,
OpenArgs was only supported for Forms.)
And, as fredg points out, if you want people to assist you in debugging your
code, you not only have to give them the details about where and how you use
it, but you need to provide it. We are only equipped to answer technical
questions, not to do a mind-link to know what you are talking about and then
answer the technical questions -- Sorry.
Larry Linson
Microsoft Access MVP