G
Guest
I have posted code below that I am using on my checkbox(Collect) and
associated button(cmdCollect) that are both in frmProducts, a subform of
frmFollow.
At the moment, I am able to create record in frmProducts, exit frmFollow, re
enter, uncheck and recheck Collect, then click on cmdCollect and the correct
record appears in frmCollections.
However, that is the ONLY way. I don't want to have to exit , re enter,
uncheck and recheck....I just want to be able to create the record, check the
box, press the button and correct associated record appears in frmCollections.
Any idea how I can do this? Should the code be on a different event?
TIA
Private Sub Collect_AfterUpdate()
If Me.Collect = True Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblReturns ( ClaimID, CollectAndReplace )SELECT
tblClaims.pkClaimID, tblClaims.ReplacementOrder FROM tblClaims"
DoCmd.SetWarnings True
End If
Me.cmdCollect.Enabled = Nz(Me.Collect.Value, True)
End Sub
Private Sub cmdCollect_Click()
On Error GoTo Err_cmdCollect_Click
Dim intCurrentContact
intCurrentContact = Me![pkClaimID]
DoCmd.Save acDefault, tblReturns
DoCmd.Close acForm, "frmFollow"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCollections"
stLinkCriteria = "[pkClaimID]=" & intCurrentContact
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdCollect_Click:
Exit Sub
Err_cmdCollect_Click:
MsgBox Err.Description
Resume Exit_cmdCollect_Click
End Sub
associated button(cmdCollect) that are both in frmProducts, a subform of
frmFollow.
At the moment, I am able to create record in frmProducts, exit frmFollow, re
enter, uncheck and recheck Collect, then click on cmdCollect and the correct
record appears in frmCollections.
However, that is the ONLY way. I don't want to have to exit , re enter,
uncheck and recheck....I just want to be able to create the record, check the
box, press the button and correct associated record appears in frmCollections.
Any idea how I can do this? Should the code be on a different event?
TIA
Private Sub Collect_AfterUpdate()
If Me.Collect = True Then
DoCmd.SetWarnings False
DoCmd.RunSQL "INSERT INTO tblReturns ( ClaimID, CollectAndReplace )SELECT
tblClaims.pkClaimID, tblClaims.ReplacementOrder FROM tblClaims"
DoCmd.SetWarnings True
End If
Me.cmdCollect.Enabled = Nz(Me.Collect.Value, True)
End Sub
Private Sub cmdCollect_Click()
On Error GoTo Err_cmdCollect_Click
Dim intCurrentContact
intCurrentContact = Me![pkClaimID]
DoCmd.Save acDefault, tblReturns
DoCmd.Close acForm, "frmFollow"
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmCollections"
stLinkCriteria = "[pkClaimID]=" & intCurrentContact
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdCollect_Click:
Exit Sub
Err_cmdCollect_Click:
MsgBox Err.Description
Resume Exit_cmdCollect_Click
End Sub