Help troubleshoot Write Conflict

Dairy Farmer

Registered User.
Local time
Today, 10:05
Joined
Sep 23, 2010
Messages
244
Access 2007, single machine.

I have a form that is split into 2 parts.
An unbound list box (to select an animal).
A sub form that contains field related to an animal and (in the footer) a Tab Control (2 pages).

Page 1 is for entering medical treatments.
Page 2 is for enetring lactations (calvings).

I am having problems with the calvings.

Select an animal from the List Box.
Goto Page 2 in the Tab Control.
Enter details about the calving (calf number, DOB,....)
On saving the new calf is added to the List Box.
Saving, adding and deleting work fine.
Calvings are appended to a second table with an autonumbering PK.
The calf number is also appended to the main animal table.
Editing is the problem.
After editing and click on the save button, another form is opened and data is appended.
Data is appended at this stage.
List box is updated if the calf number has been changed.
All fine so far.

Now if you select the calf in the List Box you get the "Write Conflict" message.
Clicking on "Save record" or "Drop Changes" works fine as the data is already appended.
All this is fine except I would like to get rid of the Write Conflict.

If I add a acCmdSaverecord to the code, the Write Conflict is resolved, but the data is not appended correctly. A
new record is made using the PK. The old record is retained in the main animal table but not in the calving
table.

Code (second half not shown as it for new records)
Private Sub Button_Save_Click()
'DoCmd.RunCommand acCmdSaveRecord (removed as it adds a new record)
If DLookup("CalfNumber", "T_Calvings", "IDCalvings = IDCalvings2") Then
On Error Resume Next

DoCmd.OpenForm "F_Animals3", acNormal, "",
"[Forms]![F_Animal]![F_Animal2].[Form]![F_Calvings].[Form]![CalfNumber]", acEdit, acNormal
Forms("F_Animals3").AnimalNumber1 = CalfNumber
Forms("F_Animals3").AnimalNumber2 = CalfName
Forms("F_Animals3").AnimalSex = CalfSex
Forms("F_Animals3").AnimalDOB = DateCalvings
Forms("F_Animals3").AnimalBreed = [Forms]![F_Defaults]![DefaultBreed]
Forms("F_Animals3").AnimalGroup = CalfGroup
Forms("F_Animals3").AnimalInMilk = 0
Forms("F_Animals3").Dame = AnimalCalvings
DoCmd.Close acForm, "F_Animals3"

MsgBox "Calf details updated", vbInformation, "UPDATE CALF"

DoCmd.Requery ""
Forms!F_Animal.AnimalList.Requery
Forms!F_Animal.Requery
Else
 

Users who are viewing this thread

Back
Top Bottom