Update data

T

Tom Brown

I have a data entry form that lets me add records to a table (and the
related query). I have a Cmd Button on the form that allows me to Preview
a Report showing the data entered. Sometimes, the data I have just entered
is not on the report.

I think I need to tell it to Requery or Refresh when I print the report.
But, when I add an Event Procedure that has DoCmd.Requery, it gives me an
error and it looks like it is not accessing the table, but just looking for
a control in the form.

How can I tell Access to go to the underlying table and refresh to make sure
all new records are written and recorded?

Any help will be appreciated.

TIA,

Tom
 
M

Marshall Barton

Tom said:
I have a data entry form that lets me add records to a table (and the
related query). I have a Cmd Button on the form that allows me to Preview
a Report showing the data entered. Sometimes, the data I have just entered
is not on the report.

I think I need to tell it to Requery or Refresh when I print the report.
But, when I add an Event Procedure that has DoCmd.Requery, it gives me an
error and it looks like it is not accessing the table, but just looking for
a control in the form.

How can I tell Access to go to the underlying table and refresh to make sure
all new records are written and recorded?


You can never be sure what object DoCmd.Requery is operating
on. If you really need to requery the form's recordset,
then use Me.Requery.

I think all you need it to make sure any edits to the form's
current record are saved before opening the report. The
code that I use for this is:
If Me.Dirty Then Me.Dirty = False
 
Top