Updating a bound form's record from an unbound form

R

Ron Kunce

I need to update a record from two different forms. One is a bound form
which calls an unbound form which can change other fields in the same record
of the calling bound form. My original solution was to write all the fields
from the unbound form to hidden fields on the bound form and is saved to the
table when the bound form is saved/closed. However, the unbound form has
been expanded to call a report which needs updated data before the bound
forms is saved. I have tried to use a recordset to update the record from
the unbound form, but this invokes a write error/warning stating that
another user has changed the record when returning to the calling bound
form. I have tried to have the unbound form write the data to the bound
found and tell to bound form to save itself, as in:

Forms!frmReferralUpdate.txtProbateFileDate = Me.txtProbateFileDate
Forms!frmReferralUpdate.txtProbateCloseCode = Me.txtProbateCloseCode
Forms!frmReferralUpdate.txtProbateCloseDate = Me.txtProbateCloseDate
Forms!frmReferralUpdate.txtReferralDate.SetFocus
Forms!frmReferralUpdate.SaveReferral
Me.txtDateOfDeath.SetFocus

However, this only works when stepping through the code in debug mode, while
running it normally fails to execute the call to bound forms SaveReferral
method. Inserting a timing delay loop does no good. I do not understand
why it steps through the code perfectly but won't run normally.

I figure the best way would be to rewrite the bound form as a unbound form
and use a class module to get and update the data, but that would be a lot
of re writing. the original bound form has too many fields and code and
would take a long time to do it right. Does anyone know of an easier
solution?
 
R

Rob Oldfield

I don't really understand exactly what it is that you're trying to do, and
why you can't just bind the unbound form to your table... but can you not do
something like...

When the bound form calls the unbound form, write the record's data into a
temporary table.
Bind the unbound form to the temp table.
Base the report on the temp table.
When the form closes, write the data back to the original table.

You'll obviously have to come up with some means of stopping any other users
changing data on that record while this process is in action... but I think
you're always going to have that issue given what it is that you appear to
be trying to do.
 
R

Ron Kunce

Basing the report on a Temp table won't work. Besides, I asked for a simple
solution, which I have discovered on my own. I was busy trying to
incorporate the two forms into single form using invisible tabs, when it
dawned on me, all I had to do was close the original calling form when I
opened the second form then reopen the calling form when I closed the second
form. This works and avoids the conflict of trying to update the same
record from two different open forms.

I knew there had to be a simple solution, I am just getting too rusty with
my VB coding being in the process of converting my skill set to doing Java
web apps. Thanks anyway.


I don't really understand exactly what it is that you're trying to do, and
why you can't just bind the unbound form to your table... but can you not
do
something like...

When the bound form calls the unbound form, write the record's data into a
temporary table.
Bind the unbound form to the temp table.
Base the report on the temp table.
When the form closes, write the data back to the original table.

You'll obviously have to come up with some means of stopping any other
users
changing data on that record while this process is in action... but I think
you're always going to have that issue given what it is that you appear to
be trying to do.
 

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