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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referencing 2 layers of subforms 1

Status
Not open for further replies.

llafretaw

MIS
Oct 2, 2001
64
GB
Hi,
Currently I have a main form (frmMain), which has one subform (sfrmSubMain), which itself is made up of two sub forms(sfrmSubSub1 & sfrmSubSub2).
I'm trying to set it up, so if the user moves to record 5 for example in sfrmSubSub1, the focus in sfrmSubSub2 switches to record 5 as well and vice versa.
I have tried variants of the below code in the lowest subform but kept getting errors saying that either "sfrmSubMain" doesn't exist or is not opened even though the main form of which it is a sub form is open.

forms![frmMain]![sfrmSubMain]![sfrmSubSub2].bookmark= me.bookmark
or
forms![frmMain]![sfrmSubMain]![sfrmSubSub1].form.bookmark= me.bookmark
or
forms![frmMain]![sfrmSubMain]!Forms![sfrmSubSub1].bookmark= me.bookmark

and so on but to no avail, any help would be appreciated.

thanks,
 
A subform is a control contained in the main form. It is not open, so the message is correct.

Me.Bookmark refers to the bookmark of the object, so using bookmarks across subforms is not a good idea, actually you could end up with errors.

You could however, use the RecordsetClone of the subform2 combined with FindFirst to search for a mathcing record.

Open the subform1 and place the following code in the Current event:

With Me.Parent("Subform2").Form.RecordsetClone
.FindFirst "IDFieldInSubForm2 = " & IDFieldInSubform1
If .NoMatch Then Exit Sub
Me.Parent("SubformName").Form.Bookmark = .Bookmark
End With

Or something like this...

[pipe]
Daniel Vlas
Systems Consultant
 
Cheers for your help, it was much appreciated as I got it working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top