Write Conflict

  • Thread starter Thread starter MikeA
  • Start date Start date
M

MikeA

I've got a popup/modal type of form to allow entering
more detail information about a contact from my main data
form. This contact info is from the same record as the
main form is currently displaying. About 75% of the time
I only need to enter the first couple fields, so I placed
those on the main form. The rest of the fields are on the
contact popup.

The contact form is bounded and it's tied to the main
key. I receive the Write Conflict error if I start to
type into the first couple fields, then decide to open
the more detail form.

How do I synchronize these fields and their underlying
record? I'd also like to unbound the contact form so
that I can Undo the whole record including anything typed
into the popped up contact form.

I'm a little weak on the Access programing and would like
suggestions on where to find more information. I've got
the Inside Out Access book, but it's pretty thin on VBA
details.

Thanks for your help!

Mike A
 
Mike,

The problem that you are having most likely stems from the
fact that your first record you are entering is still
hanging half way through the data entry mode and hasn't yet
been 'committed' to the table when you call the popup which
will attempt to write to the same incomplete record.

To solve this, you should put the following line in the code
of your command button that calls the popup form...

Me.Dirty = False

This will commit the record to the table.

You also say you want...
I'd also like to unbound the contact form so
that I can Undo the whole record including anything typed
into the popped up contact form.

You can use unbound forms, but if your VBA skills are still
in a learning curve, you will have a challenge there. Your
conundrum here is that you need to commit the first half of
the record before you can enter the second half. With this
approach, your only undo for the whole thing would be to do
it by Edit/DeleteRecord or to do it with code behind the
scenes using a Delete command button

There are other approaches, such as having all the controls
on one form, but keeping the ones you don't need hidden
until you decide that you do need them and then turning
their visible property on. With this approach, just hitting
ESC a couple of times would undo everything.

Gary Miller
Sisters, OR
 
Gary, Thanks for the feedback.

I thought about committing the first record before
displaying the popup. But I've already placed an Undo
button on the first screen. I'd like to be able to
cancel ALL updates including what might have been entered
on the popup.

Is it possible to "hold" the values from the popup form
until the main form is either saved, or rolled back?

I can't really add all the controls to the main screen
and just hide them. At least it would seem to be very
cumbersome: I have a fairly thin band at the top of the
form with a few fields like the key, status, and the
first contact fields. The bottom half of the form is a
four tab control. The popup contact form has 12 fields
and it seems to really need its own form to hold all of
them.

My programming skills are pretty good...just not
Access...at least not since 2.0... If you've got some
suggestions on how to get better at this, I'd be
interested.

(Hmm. I just noticed the Forms "Programming" newsgroup
Should I be posting these kind of questions there?)

Thanks,
Mike.
 
Add your 12 extra controls to the main form and hide them.
Make sure the controls on your pop-up form are named the same as on the main
form.
Leave your main form in edit mode and open your pop-up.
In the code behind the button to close the pop-up, place the following code.
(air code)
===========================
Dim ctL as Control

For each ctL in Me.Controls
If ctL.ControlType = acTextBox Then
Forms!YourMainForm(ctL.Name).Value = ctL .Value
End If
Next

DoCmd.Close acForm, Me.Name
============================
Of course, you can also use other types of controls like checkboxes, combo
boxes, etc. Just add to the code.
Your main form will still be in edit mode so your undo will still work.
 
In light of what you are saying here, I see a couple of
choices. If you don't want to commit the first form before
entering into the second, you could do 'Visible = False' on
the second one instead of closing it after entering into it
and then trap everything in the BeforeUpdate of the first
form, verify that they want to save and if so roll through
the controls on the second form and and save the appropriate
values to their fields. This would involve making the second
form unbound, maybe even with one hidden bound field that
you would populate for every unbound entry field. Awful
cumbersome.

Probably the best way would be to go ahead and commit the
first form's record, bring up the second form and do your
entry, go back to the first and then prompt the user for the
save at some point before they leave the record. You could
easily delete through a SQL statement or a saved Delete
query referencing the ID on the form. Problem is, you have
now missed your Before and AfterUpdate events if they enter
nothing more.

I am a bit curious that you wouldn't know whether you want
to keep the record or not by the time you want to enter all
the additional info.

Gary
 
Back
Top