Linking subforms

rkmaitra

Registered User.
Local time
Today, 09:42
Joined
Jul 11, 2011
Messages
40
Hello,
I have two forms, both based on the same database. Form1 is in single form view, Form2 is in datasheet view. I am trying to combine the two forms. I have created a blank form and added the two forms as subform controls. Now I need to make sure that when I click on a record in the datasheet subform (Form2), the same record is displayed in the single view subform (Form1). To that end, I have created a text box to track the record number of subform (Form2). When I try and link the single view subform (Form1) master and child fields, I am getting the error - cannot build links between unbound forms.
Any help would be appreciated.
NB - I have tried a split-form, but that is not acceptable for other reasons.
Many thanks,
Rudra
 
You could use the FindRecord method to locate the required record on your Form1 the code might look something like;

Code:
    Dim srchVar As String
    
    srchVar = Me.RecordID
    
    Forms!formMaster!form1.SetFocus
    Forms!formMaster!form1.Form!RecordID.SetFocus
    DoCmd.FindRecord srchVar, acAnywhere, , acSearchAll, , acCurrent
Note: that when setting focus to a control on a Sub form you must first set the focus to the sub form holder before setting focus to the required control on the sub form.

The attached sample has a working example.
 

Attachments

Users who are viewing this thread

Back
Top Bottom