Frustrated - Error Messages Regarding Save

G

Guest

I have a continuous form that pulls up all or some records. Then I can click
on a button beside each record to open up another form that brings up its
details.

The problems is that either 1) whenever I change something on the first
continuous form and open up the detailed form and start editing, or 2) I
close the detailed form after updating something and edit the same record on
the first continuous form, the following errors appear:

1) Write Conflict
2) Another user edited this record and saved the changes before you
attempted to save your changes. Re-edit the record.

I have tried adding a me.refresh command onto the close button of the
detailed form and the button that pulls up the detailed form. The error
messages disappeared but it’s very annoying sometimes that the form keep
refreshing!

I have read some comments on write-conflict and noticed that using me.dirty
might be a better way to fix this problem. However, I am not very good at
code. Could anyone help me out? Thanks * 100000
 
G

Guest

I have read some comments on write-conflict and noticed that using me.dirty
might be a better way to fix this problem.

Then you've already investigated the problem and found the solution: save
the record _before_ you start editing it in another form.
However, I am not very good at
code.

Nearly all of the code needed is already written in your button's OnClick( )
event. You've got code that opens the Details form. Right? Try both of
these methods below and see which one you like better:

RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmDetailsForm"

.. . . or:

Me.Dirty = True
DoCmd.OpenForm "frmDetailsForm"

.. . . where frmDetailsForm is the name of the Details form.

When returning from the Details form, save the record before closing that
form. This can be in the "Close" button's OnClick( ) event or in the form's
OnClose( ) event, but it's more reliable when placed in the form's OnClose( )
event, because users don't always use buttons to close forms. In the Details
form, try:

Private Sub Form_Close()

On Error GoTo ErrHandler

RunCommand acCmdSaveRecord

Exit Sub

ErrHandler:

MsgBox "Error in Form_Close( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear

End Sub
However, I am not very good at
code.

I think we can agree that the code above is a cake walk. And now you can
get rid of those annoying Me.Refresh commands.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
G

Guest

Thanks for replying :)

However, the message box still pops up whenever I change something on the
detailed form, close the detailed form, return back to the continuous form
with all the records (note that I do not have to open this form coz it is not
closed in the first place), and change something on the continuous form.

Another thing is that when I type the me.dirty command in the open button of
the continuous form, the following message pops up:
"Run-time error 7768": In order to change data through this form, the focus
must be a bound field that can be modified.
 

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