Can I Suppress Write Conflict Message?

C

cmw

My application uses VB code to perform a variety of validations on data
entered on a form. There are edit, cancel and save buttons.

User encounters a "Write Conflict" message box on the save button. Can this
message box be suppressed? The set warnings flag does not work on this
message. I've tried changing the record locking setting on the options menu,
doesn't appear to have any impact.

Edit Button - when clicked, the system performs validations and writes data
to the table. The user may add or update additional data.
Cancel Button - executes DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70 (undoes the user entered data) then overlays data added on Edit
click
Save Button - executes DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70 which results in a message box "Write Conflict"
followed by an explanation and 2 choices, "Copy to Clipboard" or "Drop
Changes".

Thanks
 
G

Graham Mandeno

Hi cmw

I don't quite understand the function of the Edit button. You say:
Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.

I suspect this is what is causing your problem. If this button writes data
to the same record that is current on your form, then when the Save button
is clicked, Access will detect that the data in the underlying table has
been changed since it was loaded into the form and that will give you the
"write conflict" message.

What exactly IS the purpose of having both an Edit and a Save button?

As an aside, DoMenuItem is obsolete. (A hint which supports this is in the
"acMenuVer70" - version 7.0 was Access 95!!. Yes, I know the code wizard
still generates code using DoMenuItem, but wizards are notoriously old with
long grey beards :)

Instead, to undo changes to the current record, use:
Me.Undo

and to save changes to the current record, use either:
Me.Dirty = False
or
DoCmd.RunCommand acCmdSaveRecord
 
C

cmw

Hi Graham -

When the form is opened, the Allow Updates property is false, the edit
button sets the property to true, determines which fields can be edited based
on the user's credentials and writes data to the table.

When the record is saved, the data the user entered on the window is saved
(cancelled performs an undo). I know it's the write to the table that causes
the problem, programming logic makes the determination what "system" data to
update, the user doesn't. The save button saves the user's changes. I'd like
to suppress the popup so the user doesn't get what is percieved to be an
error message.

I'll look into changing the code to DoCmd.RunCommand acCmdSaveRecord. This
was my first application in Access - I used examples from books and the help
menus to develop it. It's been in use a few years, the newer code is more up
to date, but this is the oldest window.

Thanks
Graham Mandeno said:
Hi cmw

I don't quite understand the function of the Edit button. You say:
Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.

I suspect this is what is causing your problem. If this button writes data
to the same record that is current on your form, then when the Save button
is clicked, Access will detect that the data in the underlying table has
been changed since it was loaded into the form and that will give you the
"write conflict" message.

What exactly IS the purpose of having both an Edit and a Save button?

As an aside, DoMenuItem is obsolete. (A hint which supports this is in the
"acMenuVer70" - version 7.0 was Access 95!!. Yes, I know the code wizard
still generates code using DoMenuItem, but wizards are notoriously old with
long grey beards :)

Instead, to undo changes to the current record, use:
Me.Undo

and to save changes to the current record, use either:
Me.Dirty = False
or
DoCmd.RunCommand acCmdSaveRecord
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


cmw said:
My application uses VB code to perform a variety of validations on data
entered on a form. There are edit, cancel and save buttons.

User encounters a "Write Conflict" message box on the save button. Can
this
message box be suppressed? The set warnings flag does not work on this
message. I've tried changing the record locking setting on the options
menu,
doesn't appear to have any impact.

Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.
Cancel Button - executes DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, ,
acMenuVer70 (undoes the user entered data) then overlays data added on
Edit
click
Save Button - executes DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70 which results in a message box "Write
Conflict"
followed by an explanation and 2 choices, "Copy to Clipboard" or "Drop
Changes".

Thanks
 
G

Graham Mandeno

Hi cmw

What are the fields that you are changing in code? Can you post the code
for your Edit button?

If they are fields such as "LastChangeDate" and "LastChangedBy" then the
best place to set these is in the BeforeUpdate event of the form after the
user clicks the Save button. The point is that if your code changes the
fields in the current record of the form's recordset, it won't be seen as
two independent streams editing the same record at the same time.

Oh, your Edit button will still need to set AllowUpdates, but that is all.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

cmw said:
Hi Graham -

When the form is opened, the Allow Updates property is false, the edit
button sets the property to true, determines which fields can be edited
based
on the user's credentials and writes data to the table.

When the record is saved, the data the user entered on the window is saved
(cancelled performs an undo). I know it's the write to the table that
causes
the problem, programming logic makes the determination what "system" data
to
update, the user doesn't. The save button saves the user's changes. I'd
like
to suppress the popup so the user doesn't get what is percieved to be an
error message.

I'll look into changing the code to DoCmd.RunCommand acCmdSaveRecord. This
was my first application in Access - I used examples from books and the
help
menus to develop it. It's been in use a few years, the newer code is more
up
to date, but this is the oldest window.

Thanks
Graham Mandeno said:
Hi cmw

I don't quite understand the function of the Edit button. You say:
Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.

I suspect this is what is causing your problem. If this button writes
data
to the same record that is current on your form, then when the Save
button
is clicked, Access will detect that the data in the underlying table has
been changed since it was loaded into the form and that will give you the
"write conflict" message.

What exactly IS the purpose of having both an Edit and a Save button?

As an aside, DoMenuItem is obsolete. (A hint which supports this is in
the
"acMenuVer70" - version 7.0 was Access 95!!. Yes, I know the code wizard
still generates code using DoMenuItem, but wizards are notoriously old
with
long grey beards :)

Instead, to undo changes to the current record, use:
Me.Undo

and to save changes to the current record, use either:
Me.Dirty = False
or
DoCmd.RunCommand acCmdSaveRecord
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


cmw said:
My application uses VB code to perform a variety of validations on data
entered on a form. There are edit, cancel and save buttons.

User encounters a "Write Conflict" message box on the save button. Can
this
message box be suppressed? The set warnings flag does not work on this
message. I've tried changing the record locking setting on the options
menu,
doesn't appear to have any impact.

Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.
Cancel Button - executes DoCmd.DoMenuItem acFormBar, acEditMenu,
acUndo, ,
acMenuVer70 (undoes the user entered data) then overlays data added on
Edit
click
Save Button - executes DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70 which results in a message box "Write
Conflict"
followed by an explanation and 2 choices, "Copy to Clipboard" or "Drop
Changes".

Thanks
 
C

cmw

The code is updating an "Record in Use" type of field. I can't use the
BeforeUpdate as I need the field to be updated to prevent other users from
attempting to update same record.

I figured out another way - on the edit click, I check to see if the record
is in use, if it's not, I set it and save it (using the DoCmd.RunCommand
acCmdSaveRecord). On the Cancel click, if it's dirty, I undo (removing the
changes made on the window), then regardless of if dirty or not, update the
Record in Use to null and save the record before setting the allowupdates to
false.

Seems to be working okay.

Thanks for the tip on the saving.

Graham Mandeno said:
Hi cmw

What are the fields that you are changing in code? Can you post the code
for your Edit button?

If they are fields such as "LastChangeDate" and "LastChangedBy" then the
best place to set these is in the BeforeUpdate event of the form after the
user clicks the Save button. The point is that if your code changes the
fields in the current record of the form's recordset, it won't be seen as
two independent streams editing the same record at the same time.

Oh, your Edit button will still need to set AllowUpdates, but that is all.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

cmw said:
Hi Graham -

When the form is opened, the Allow Updates property is false, the edit
button sets the property to true, determines which fields can be edited
based
on the user's credentials and writes data to the table.

When the record is saved, the data the user entered on the window is saved
(cancelled performs an undo). I know it's the write to the table that
causes
the problem, programming logic makes the determination what "system" data
to
update, the user doesn't. The save button saves the user's changes. I'd
like
to suppress the popup so the user doesn't get what is percieved to be an
error message.

I'll look into changing the code to DoCmd.RunCommand acCmdSaveRecord. This
was my first application in Access - I used examples from books and the
help
menus to develop it. It's been in use a few years, the newer code is more
up
to date, but this is the oldest window.

Thanks
Graham Mandeno said:
Hi cmw

I don't quite understand the function of the Edit button. You say:

Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.

I suspect this is what is causing your problem. If this button writes
data
to the same record that is current on your form, then when the Save
button
is clicked, Access will detect that the data in the underlying table has
been changed since it was loaded into the form and that will give you the
"write conflict" message.

What exactly IS the purpose of having both an Edit and a Save button?

As an aside, DoMenuItem is obsolete. (A hint which supports this is in
the
"acMenuVer70" - version 7.0 was Access 95!!. Yes, I know the code wizard
still generates code using DoMenuItem, but wizards are notoriously old
with
long grey beards :)

Instead, to undo changes to the current record, use:
Me.Undo

and to save changes to the current record, use either:
Me.Dirty = False
or
DoCmd.RunCommand acCmdSaveRecord
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand


My application uses VB code to perform a variety of validations on data
entered on a form. There are edit, cancel and save buttons.

User encounters a "Write Conflict" message box on the save button. Can
this
message box be suppressed? The set warnings flag does not work on this
message. I've tried changing the record locking setting on the options
menu,
doesn't appear to have any impact.

Edit Button - when clicked, the system performs validations and writes
data
to the table. The user may add or update additional data.
Cancel Button - executes DoCmd.DoMenuItem acFormBar, acEditMenu,
acUndo, ,
acMenuVer70 (undoes the user entered data) then overlays data added on
Edit
click
Save Button - executes DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70 which results in a message box "Write
Conflict"
followed by an explanation and 2 choices, "Copy to Clipboard" or "Drop
Changes".

Thanks
 

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

Similar Threads


Top