I'm using Access 2003.
I have a subform that is nested two levels deep (it has a parent and a grandparent form). In the AfterUpdate event of the subform, I requery the grandparent and parent forms (and restore to the same records displayed before the subform update), then I requery the subform and attempt to set the focus to the first field on the subform.
My code looks like this:
(I need to requery the parent forms because there are calculated fields on the parents that depend on data in the subform.)
All works fine *except* that the final SetFocus does not seem to work. In fact the focus is no longer even in the subform, but rather on the grandparent form. (After the above code runs, if I press tab, I'm tabbing through the grandparent form.)
Any idea why? I'd like to still be tabbing in the subform after this code runs.
Thanks for any help you can give.
Wayne
I have a subform that is nested two levels deep (it has a parent and a grandparent form). In the AfterUpdate event of the subform, I requery the grandparent and parent forms (and restore to the same records displayed before the subform update), then I requery the subform and attempt to set the focus to the first field on the subform.
My code looks like this:
Code:
Private Sub Form_AfterUpdate()
On Error GoTo Err_Form_AfterUpdate
Dim rs As Object
Dim lngClaimBookmark, lngClaimPartyBookmark, lngLoadingID As Long
'Set bookmarks
lngClaimBookmark = Me.Parent.Parent.ClaimID
lngClaimPartyBookmark = Me.Parent.ClaimPartyID
lngLoadingBookmark = Me.LoadingID
'Requery the Claim form
Me.Parent.Parent.Requery
'Go back to original Claim
Set rs = Me.Parent.Parent.RecordsetClone
rs.FindFirst "ClaimID = " & lngClaimBookmark
Me.Parent.Parent.Bookmark = rs.Bookmark
'Requery the ClaimParty form
Me.Parent.Requery
'Go back to the original ClaimParty
Set rs = Me.Parent.RecordsetClone
rs.FindFirst "ClaimPartyID = " & lngClaimPartyBookmark
Me.Parent.Bookmark = rs.Bookmark
'Requery the Loading form
Me.Requery
'Go back to the original Loading
Set rs = Me.RecordsetClone
rs.FindFirst "LoadingID = " & lngLoadingBookmark
Me.Bookmark = rs.Bookmark
Me.txtContractNumber.SetFocus
Set rs = Nothing
Exit_Form_AfterUpdate:
Exit Sub
Err_Form_AfterUpdate:
Cancel = True
MsgBox Err.Description
Resume Exit_Form_AfterUpdate
End Sub
(I need to requery the parent forms because there are calculated fields on the parents that depend on data in the subform.)
All works fine *except* that the final SetFocus does not seem to work. In fact the focus is no longer even in the subform, but rather on the grandparent form. (After the above code runs, if I press tab, I'm tabbing through the grandparent form.)
Any idea why? I'd like to still be tabbing in the subform after this code runs.
Thanks for any help you can give.
Wayne