Go To New Record On Subform After Closing Pop Up Form

ErinL

Registered User.
Local time
Today, 13:40
Joined
May 20, 2011
Messages
118
Hi Everyone -

I have a form (frmAuditEntry) that includes a subform (sfrmAuditDetail). The user will enter audit information on the subform. There is a check box on the subform to identify containers that had errors in selection. When the box is check by the user, a pop up form opens where the user can enter the details regarding the type of error. The audit number and the container ID are carried over from the main form to the pop up form to link the information.

This is the code I have in the AfterUpdate event of the checkbox:

Private Sub Errors_AfterUpdate()
Dim rs As Object
Dim strBookmark As String
strBookmark = Me.ContainerID

Me.Requery

Set rs = Me.RecordsetClone
rs.FindFirst "ContainerID = '" & strBookmark & "'"
Me.Bookmark = rs.Bookmark
Set rs = Nothing

If Me.Errors.Value = True Then
DoCmd.RunMacro "macAppendErrorDetailInfo"
DoCmd.OpenForm "pfrmErrorDetail", acNormal, , , acFormEdit, acWindowNormal
Else
End If

Set rs = Me.RecordsetClone
rs.FindFirst "ContainerID = '" & strBookmark & "'"
Me.Bookmark = rs.Bookmark
Set rs = Nothing

End Sub

This works great and keeps the focus on the record the user checked having errors so the right information transfers tot he pop up form fields. When the pop up form is closed, the focus goes back to the subform but keeps the focus on the container ID control of the record that the user previously checked as having errors (hope that makes sense).:o

What I would like to happen is this: When the pop up form is closed, I want the focus to go back to the subform but to go to the last blank record on the subform (if the user moved off the record before checking the error checkbox) or go to a new record (if the user did not move to a new record already before checking the error checkbox).

Hopefully I explained this adequately. :confused: Any assistance will be greatly appreciated as I have been trying to figure this out on my own for some time without any luck.

Thank you in advance!
 

Users who are viewing this thread

Back
Top Bottom