loosing a focus on a parent form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a continuos form with a subform placed in the footer of the form. The
subform is also a continuos form.

When I update/enter records in a subform. I would like to requery the
parent form and stay on the same record. In other words I just want to
update the parent records without changing a focus.

I use an after update event with

Me.Parent.Requery

which works fine apart of loosing a right focus.

Let's say that stay on a line in a subform (linking to the 3rd row on the
parent form). When I run
Me.Parent.Requery the focus changes to the Parent form, but always to the
first row of the form
Does anyone know how to stay on the current "parent record" (3d line) after
requering the form?

thanks for your hepl
 
Here is a routine I have in a standard module that can be called from any
form. In your case, you will want to call it like this:

Call DelCurrentRec(Me.Parent)

Public Sub DelCurrentRec(ByRef frmSomeForm As Form)
Dim rst As Recordset

On Error GoTo DelCurrentRec_Error

Application.Echo False
With frmSomeForm
Set rst = .RecordsetClone
rst.Bookmark = .Bookmark
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MoveNext
Else
.Recordset.MovePrevious
End If
rst.Delete
If .Recordset.AbsolutePosition > 0 Then
.Recordset.MovePrevious
Else
.Recordset.MoveNext
End If
End With

DelCurrentRec_Exit:

On Error Resume Next
rst.Close
Set rst = Nothing
Application.Echo True
Exit Sub

DelCurrentRec_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure DelCurrentRec of Module modFormOperations"
GoTo DelCurrentRec_Exit

End Sub
 
Back
Top