Recordset.FindFirst in MainFrm AND! SubFrm ?

piet123

piet
Local time
Tomorrow, 00:38
Joined
May 24, 2004
Messages
66
Hello,
In Access 2000 :

I have a custom search form with a ListBox. The ListBox gets it's records from a Query where the MainTable and RelatedTable is linked.

On the DoubleClick event of the ListBox (ListInstruments) I have the following code: (This works perfectly as it should)

DoCmd.OpenForm "frm_Instruments"
Set Recordset = Forms!frm_Instruments.Recordset.Clone
Recordset.FindFirst "[instrmain_id] = " & Me.ListInstruments
Forms!frm_Instruments.Bookmark = Recordset.Bookmark
DoCmd.Close acForm, "frm_Mycustomsearch"
Exit_ListInstruments_DblClick:

In the above listbox is the Maintable PK_id as well as the related 'Sub'Table's PK_id and the relationship ID.

The 'search results' form (frm_Instruments) has a subform for the related records.

What I'm trying to do is :

On the ListBox's double-click event, I want it to go to frm_Instruments and find the 'Main Record' AND THEN also find the 'Sub-Record'.

So I'm thinking something like in the code below, but not sure where to go because I've tried several options, none of which worked:

DoCmd.OpenForm "frm_Instruments"
Set Recordset = Forms!frm_Instruments.Recordset.Clone
Recordset.FindFirst "[instrmain_id] = " & Me.ListInstruments
Forms!frm_Instruments.Bookmark = Recordset.Bookmark
>>> Recordset.FindFirst "[instrSUB_id] = " & Me.ListInstruments
>>> Forms!frm_Instruments.SUBfrmInstruments.Bookmark = Recordset.Bookmark
DoCmd.Close acForm, "frm_Mycustomsearch"
Exit_ListInstruments_DblClick:

Any advice please.
Thank You.
 
>>> Forms!frm_Instruments.SUBfrmInstruments.Bookmark = Recordset.Bookmark

Becomes:

Forms("SUBfrmInstruments")!Form.Bookmark = Recordset.Bookmark

That should do it.
 

Users who are viewing this thread

Back
Top Bottom