G
Guest
I have a table with 3 Fields. OrgID, AssociatedID and AssociationID.
From a form I capture the data for OrgID and AssociatedID. I have some code
the worked under office 97 to save this data, then invert AssociatedID and
OrgID and save again. Since upgrading only the second half of the operation
is commited, it seems like the first part is not. What am I missing? I am
not a developer so please keep it simple. Here is the code.
Private Sub cmdSave_Click()
On Error GoTo errhandler
' Validate fields
If IsNull(AssociatedID) Then
MsgBox "[Associated Org]", , "Mandatory Field"
AssociatedID.SetFocus
Exit Sub
End If
If IsNull(StartDate) Then StartDate = Date
' Save current association
OrgID = [Forms]![frmMainMenu]![OrgID]
AssociationID = NextID("T_Association", "AssociationID")
If Me.Dirty = True Then
Me.Dirty = False
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
' Save associated association
Dim tmpId As Long
tmpId = OrgID
OrgID = AssociatedID
AssociatedID = tmpId
Me.Dirty = False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
exitsub:
Exit Sub
errhandler:
Select Case Err
Case 3022
' MsgBox "The organizations are already associated to each
other.", , "Info"
' Me.Undo
SetDefaults
Case Else
ErrorMessage "frmAddAssociation - cmdSave_Click()", Err,
Err.Description
Me.Undo
DoCmd.Close acForm, Me.Name
End Select
End Sub
From a form I capture the data for OrgID and AssociatedID. I have some code
the worked under office 97 to save this data, then invert AssociatedID and
OrgID and save again. Since upgrading only the second half of the operation
is commited, it seems like the first part is not. What am I missing? I am
not a developer so please keep it simple. Here is the code.
Private Sub cmdSave_Click()
On Error GoTo errhandler
' Validate fields
If IsNull(AssociatedID) Then
MsgBox "[Associated Org]", , "Mandatory Field"
AssociatedID.SetFocus
Exit Sub
End If
If IsNull(StartDate) Then StartDate = Date
' Save current association
OrgID = [Forms]![frmMainMenu]![OrgID]
AssociationID = NextID("T_Association", "AssociationID")
If Me.Dirty = True Then
Me.Dirty = False
End If
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
' Save associated association
Dim tmpId As Long
tmpId = OrgID
OrgID = AssociatedID
AssociatedID = tmpId
Me.Dirty = False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, Me.Name
exitsub:
Exit Sub
errhandler:
Select Case Err
Case 3022
' MsgBox "The organizations are already associated to each
other.", , "Info"
' Me.Undo
SetDefaults
Case Else
ErrorMessage "frmAddAssociation - cmdSave_Click()", Err,
Err.Description
Me.Undo
DoCmd.Close acForm, Me.Name
End Select
End Sub