Save Record Command

K

Ken

Im wanting to be able to create a command button that will
a) Save the current record, then
b) Open up the corresponding filtered report for that
record.

I cant work out the correct syntax to use to save the
record first before displaying the filtered report.

Any help would be appreciated

Regards

ken
 
A

Allen Browne

Set the form's Dirty property:
Me.Dirty = False

Me.Refresh is no use, as you receive no error message if the record cannot
be saved (e.g. required field missing, or validation rule not met).

RunCommand acCmdSaveRecord works, but affects whichever form currently has
focus.

The DoMenuItem nonsense has the same limitation, plus doesn't work in some
contexts.
 
D

Doug Munich

I've been doing this with Me.Recalc. Is there any drawback to doing it
that way?

Doug
 
A

Allen Browne

Recalc actually causes the form to recalculate calculated controls, i.e.
those that have an expression in their controlsource, such as:
=[Credit] - [Debit]

In doing so, it appears to force the record to save as a side effect.
Whether that works reliably, in all versions of Access (including any future
versions), who can say?
 
D

Doug Munich

So do I understand that if you have a record in the process of being
edited on a form (which makes the Dirty property True) and you set the form
Dirty property to False then that causes the record to be saved?

I figured out the Recalc way by trial and error, so I'm always interested
in learning to do things the "right" way.

Doug
 
A

Allen Browne

Yes. Exactly correct.

Access sets the Dirty property to True as soon as a bound control is
changed. You can force the record to be saved by setting it to False (unless
you are still working in Access 2 or earlier, when Dirty was read-only).

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Doug Munich said:
So do I understand that if you have a record in the process of being
edited on a form (which makes the Dirty property True) and you set the
form
Dirty property to False then that causes the record to be saved?

I figured out the Recalc way by trial and error, so I'm always
interested
in learning to do things the "right" way.

Doug


Allen Browne said:
Recalc actually causes the form to recalculate calculated controls, i.e.
those that have an expression in their controlsource, such as:
=[Credit] - [Debit]

In doing so, it appears to force the record to save as a side effect.
Whether that works reliably, in all versions of Access (including any future
versions), who can say?
 
Top