Report Shows Data from Previous Execution

G

Guest

- I have a report that is run from an underlying query.
- The query returns records from a table based on the beginning and ending
dates entered on a form.
- The same form opens the report.
- After starting the Database and displaying the report, it works perfectly
with the date range selected (ie: 6/1/2007 to 6/30/2007)
- HOWEVER .... If the user closes the report, reenters a new date range
(ie: 5/1/2007 to 5/31/2007), and reopens the report, the report opens with
the previous data (June data)
- If the user exits the database, re-starts it, and runs with May
selections, it works fine again for the first run....
- I have verified that the underlying query returns the correct records for
the date range selected on the form.

I'm stumped.
 
K

krissco

- I have a report that is run from an underlying query.
- The query returns records from a table based on the beginning and ending
dates entered on a form.
- The same form opens the report.
- After starting the Database and displaying the report, it works perfectly
with the date range selected (ie: 6/1/2007 to 6/30/2007)
- HOWEVER .... If the user closes the report, reenters a new date range
(ie: 5/1/2007 to 5/31/2007), and reopens the report, the report opens with
the previous data (June data)
- If the user exits the database, re-starts it, and runs with May
selections, it works fine again for the first run....
- I have verified that the underlying query returns the correct records for
the date range selected on the form.

I'm stumped.

Make sure you are closing the form after opening the report. If you
did something like "Me.Visible = False" then depending on how the form
is opened, the query may execute prior to the new data being provided.

You could add something like:

on error resume next
DoCmd.Close acForm, "the form name"

To Report_Close event of your report.

-Kris
 

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

Top