reference a record on another form

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.
 
A

Albert D. Kallal

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!
 

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