After searching the group and the net, I just can't believe after all
this work I'm going to have to sit through three Write Conflict
messages when I want to roll back and delete a record.
The action rolls back a new hire record, deleting it from a joining
table between employee and position - tblPosEmpRecord.
It's a many to many join.
The new hire action updates the employee with a new position and logs
it in the connecting record table.
If a user accidentally assigns the wrong position, they will need to
rollback the change and erase the connecting record, store a null in
the employee tables' position number, and store 'vacant' in the
position table for that record.
Here's the rollback:
Public Sub rollback()
On Error Resume Next
Dim temp_pos As Long
Dim temp_title As Long
Dim temp_salary As Currency
temp_pos = Forms!frmpersonnelmain!frmTAB1part4!curPos
temp_title = Forms!frmpersonnelmain!frmTAB1part4!curTitle
temp_salary = Forms!frmpersonnelmain!frmTAB1part4!curSalary
Forms!frmpersonnelmain![tblPosition.PosStatusID] = 2 'vacant
MsgBox "pos=vacant"
If Forms!frmpersonnelmain.Dirty Then
Forms!frmpersonnelmain.Dirty = False
End If
If Forms!frmpersonnelmain!frmTAB1part4!Designation = 11 Then
'<----rollback for new hire!
Forms!frmpersonnelmain![tblEmployee.PosID] = Null
If Forms!frmpersonnelmain.Dirty Then
Forms!frmpersonnelmain.Dirty = False
End If
Forms!frmpersonnelmain![cboHistFilt] = Null
MsgBox "new hire rollback REcord Deleted"
Forms!frmpersonnelmain!EmpStatus = 0 'inactive
Forms!frmpersonnelmain!frmTAB1part4!proPos.Requery
Exit Sub
End If
Forms!frmpersonnelmain!frmTAB1part4!PosID = temp_pos
Forms!frmpersonnelmain![tblEmployee.PosID] = temp_pos
Forms!frmpersonnelmain![tblPosition.JobClassID] = temp_title
Forms!frmpersonnelmain!MonthlySalary = temp_salary
Forms!frmpersonnelmain![cboHistFilt] = temp_pos
Forms!frmpersonnelmain![tblPosition.PosStatusID] = 1 'filled
MsgBox "gothere? rollback"
If Forms!frmpersonnelmain.Dirty Then
Forms!frmpersonnelmain.Dirty = False
End If
Forms!frmpersonnelmain!frmTAB1part4!proPos.Requery
End Sub
It works, I just don't like the three WRITE CONFLICT messages popping
off. It's very obnoxios.
Thanks,
Christian