Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning to a specific subform record from a popup form

Status
Not open for further replies.

dftjsn

Programmer
Feb 25, 2002
43
US

I have a Form, say FormA, which has a subform, say subFormA.
subFormA also has a subForm, say subFormB.

When the user double clicks a control on subFormB,
a popup form appears, say frmPopUp which shows all
the fields on subFormB on one form without having to scroll left and right.

When the user closes frmPopUp I want to be able to return to the same control and record number on subFormB that the user was looking at on frmPopUp (perhaps the user advanced a record or two on frmPopUp). I could do this by opening the form as a dialog form and having the control pass back into the original calling procedure, but I’m trying to do it from the close event of the frmPopUp. I am able to get the focus on the right control, but I don’t seem to be able to jump to the correct record number on subFormB during the close event of frmPopUp.

Does anyone have any suggestions on how to accomplish this so that the two forms stay in synch regardless of what record the user was looking at?

Thanks!

dftjsn
 
Try using the bookmark method. I don't normally use this feature, but a while back, I found it worked like a charm.

I would have to dig up the code at work, and I plan to enjoy the weekend for now. I will review this post in case you still have problems.

This is from MS Access help.
Code:
Private Sub cmdFindContactName_Click()
    Dim rst As adodb.Recordset, strCriteria As String
    strCriteria = "[ContactName] Like '*" & InputBox("Enter the " _
        & "first few letters of the name to find") & "*'"

    Set rst = Me.RecordsetClone
    rst.FindFirst strCriteria
    If rst.NoMatch Then
        MsgBox "No entry found"
    Else
        Me.Bookmark = rst.Bookmark
    End If
End Sub

Two things...
The RecordsetClone is a cool way to refer to the original recordset after performing such options as a filter.

The bookmark can return you to the specific record in question.

Richard
 
Richard,

Thanks for pointing me in the right direction. I was able to get it to work by assigning the form frmPopUp the same recordset as the subform:

Set Me.Recordset = Forms!FormA!subFormA.Form!subFormB.Form.Recordset

The forms stay in synch nicely.

Cheers,

dftjsn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top