D
DaveJJ
I have the following procedure that runs when I create or update a
record on a main-form and when an attached sub-form has zero records
Its purpose is to insert a default beginning record in the sub-form
table when a new record is created on the main form. This action is
only supposed to occur once on the sub-form so it is not a default
value in the normal sense. The following code works well but to be
honest I'm not sure why or if its the best approach.
The query that is fired is an append query. I was initially got
update errors with this procedure until I added DBEngine.Idle
dbRefreshCache, DoEvents in the code.
Private Sub Form_AfterUpdate()
If Nz(DCount("*", "tblRouting", "[JobEnvelopeNo] = " & Me.txtID),
0) = 0 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryInsertRoutingJobReview"
DoCmd.SetWarnings True
DBEngine.Idle dbRefreshCache
DoEvents
Me.sfrmRouting1.Form.Requery
Me.sfrmRoutingQuickLook.Form.Requery
End If
End Sub
Would appreciate any insights to better understand what is happening
here and if this is fully optimized code.
record on a main-form and when an attached sub-form has zero records
Its purpose is to insert a default beginning record in the sub-form
table when a new record is created on the main form. This action is
only supposed to occur once on the sub-form so it is not a default
value in the normal sense. The following code works well but to be
honest I'm not sure why or if its the best approach.
The query that is fired is an append query. I was initially got
update errors with this procedure until I added DBEngine.Idle
dbRefreshCache, DoEvents in the code.
Private Sub Form_AfterUpdate()
If Nz(DCount("*", "tblRouting", "[JobEnvelopeNo] = " & Me.txtID),
0) = 0 Then
DoCmd.SetWarnings False
DoCmd.OpenQuery "qryInsertRoutingJobReview"
DoCmd.SetWarnings True
DBEngine.Idle dbRefreshCache
DoEvents
Me.sfrmRouting1.Form.Requery
Me.sfrmRoutingQuickLook.Form.Requery
End If
End Sub
Would appreciate any insights to better understand what is happening
here and if this is fully optimized code.