Linking two subforms?

G

Guest

I have two subforms in a tab index on the same form and would like to link
them together. When I go to create a subform it only allows me to link it
with the main form. How would I go around this and make it work?

Thanks!
 
P

phleduc

If you have a common key field you can mirror them by using the recordset
clone method,
Could look like something like this: you can put this for example in the "on
current event" of both subforms, one in one direction, in the other one in
the other direction
'goto right client in general tab
Forms!frmClients!frmClientList1.Form.RecordsetClone.FindFirst
"[client_id]=" & Forms!frmClients.frmClientsList2.Form.CLIENT_ID
If
Forms!frmClients!frmClientList1.Form.RecordsetClone.NoMatch Then
MsgBox "client not found"
Else
Forms!fForms!frmClients!frmClientList1.Form.Bookmark
= Forms!Forms!frmClients!frmClientList1.Form.RecordsetClone.Bookmark
End If
Hope this make sense to you

Philip
 
G

Guest

They are linked by a common field in a one to one relation but they are not
the keys of the table.

This is how it is set up
I have a main form that is for the invoice
then I have a tab subform control
On the first tab is the inventory which corresponds to the invoice.
On the second tab....... This is where I want to place the vendor info.
The vendor table is related to the inventory table by a serial # field and
is a one to one relation.

I am not quite sure I understand your code???

phleduc said:
If you have a common key field you can mirror them by using the recordset
clone method,
Could look like something like this: you can put this for example in the "on
current event" of both subforms, one in one direction, in the other one in
the other direction
'goto right client in general tab
Forms!frmClients!frmClientList1.Form.RecordsetClone.FindFirst
"[client_id]=" & Forms!frmClients.frmClientsList2.Form.CLIENT_ID
If
Forms!frmClients!frmClientList1.Form.RecordsetClone.NoMatch Then
MsgBox "client not found"
Else
Forms!fForms!frmClients!frmClientList1.Form.Bookmark
= Forms!Forms!frmClients!frmClientList1.Form.RecordsetClone.Bookmark
End If
Hope this make sense to you

Philip


GregB said:
I have two subforms in a tab index on the same form and would like to link
them together. When I go to create a subform it only allows me to link it
with the main form. How would I go around this and make it work?

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Index Issues 2
Multiple Sub Forms 3
conditional tab page 1
If field =15 save in two tables 2
SubForms 4
linking to two subforms 2
number of subforms linked to one main form 1
Forms And Subforms 3

Top