reference a record on another form

  • Thread starter Thread starter CN
  • Start date Start date
C

CN

I have a button on one form that has a macro behind it
which needs to first make sure that the last row edited on
that form and other open forms is updated to the database.

Found out from an earlier post, to use
DoCmd.RunCommand acCmdSaveRecord
which works great to save the current row on the form that
my button is on but how can I do that for each of the
other open forms?

I'm trying things like
CurrentProject.AllForms(0).DoCmd.RunCommand acCmdSaveRecord
CurrentProject.AllForms(1).DoCmd.RunCommand acCmdSaveRecord
CurrentProject.AllForms(2).DoCmd.RunCommand acCmdSaveRecord

but they all give me 'invalid property' type errors. I
know this must be easy but I can't seem to find out how to
do this anywhere. Thx.
 
You always force a disk write in the current form like:


me.dirty = false.


so, you can go:

CurrentProject.AllForms(0).Dirty = false
CurrentProject.AllForms(1).dirty = False

etc.

However, I written a zillion applications and have never had to do the
above.

I do however as a rule when launching another form make sure that the
current form is written to disk FIRST before you leave. Writing out the
current record eliminates a zillion problems. In addition, if you are
controlling the flow of the user, then of course your forms are set as
model. Model forms means that the user has to return back the same way, or
"sequence" of forms opened that got the user to where they currently are.

Between write out of the current form when launching another form, and
controlling the flow of the user via model forms....there should be no
reason at all to use the above AllForms collection to start writing out all
the forms data.

Perhaps you should explain what you are trying to do, and simply not just
ask how to write out all the records for each form....as that above solution
is likely not the real problem, or solution you really need!

Good luck!
 
Back
Top