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

How to link subform on TabCtrl 1 to subform on TabCtrl2? 1

Status
Not open for further replies.

66tigger40

Technical User
May 26, 2004
108
0
0
GB
Hi
I'm slowly going mad and have fogged over... something so simple seems so complex

I have a main form which contains two tab Controls (tabMain and tabEventDetails).

The MainForm links to the first subform by PatientID

On TabMain I have a subform which contains PatientID and EventID, on TabEventDetails I have a subform called EventDetails with PatientID and EventID, I need to set the LinkChild Fields and LinkMaster Fields but everything I have tried has failed.

For Example:

Link Child Field: PatientID;[EventID]
Link Master Field: PatientID; [frmPatientEvents].form![EventID]

This only works if I press F5 to screen refresh.

What have I missed? Thanks in advance

Tigger
 
the easy way is.
1) On the main form put two textboxes: txtBxPatientLink, txtBxEventLink
leave them visible until verifying everything works. Then you can make invisible
2) In the main subform's on current event
me.Parent.txtBxPatientLink = me.patientID
me.Parent.txtBxEventLink = me.eventID

To verify this works scroll through the subform and ensure that the values in the txtBoxes change. You can make them invisible.

3) Now you can link eventdetails to the text boxes
linkParentFields: [txtBxPatientLink];[txtBxEventLink]
linkChildFields: patientID;EventID

This is probably the simplest, you could do some combinations since the Patient ID is also on the main form.

If you wanted you could just set the eventID in the on current event and link to the main forms patient id.
 
Hi
Thanks for the fast reply - tthe solution works great, but my only problem now is if I add a new Patient Event the EventID isn't written to the text box so I have added a refresh but this seems show the egg timer and waits a second or two is there a quciker way?

Thanks again

Tigger
 
probably need to add a Form_afterUpdate event in the main subform along with the on current event to set the text boxes.
me.Parent.txtBxPatientLink = me.patientID
me.Parent.txtBxEventLink = me.eventID

I think that would work
 
Hi

Thats great - all sorted, but my next problem I've come across is from one of the subforms on the second tab contol I open a new form, but I can't seem to pass the EventID and PatientID through to this form? Any pointers would be great

Tigger
 
Again there are several ways.
1) I am not a fan of the open args property, but that is one way to do it. You will have to split the string in the forms on open event. Look at the split() function to do that.
2) If you always open this "new" form from the other form then simply in the new forms on load event.

Me.eventID = forms("callingformname").subformControlName.form.eventID
...
This assumes that the calling form remains open. If you plan to close it first then you could instead hide it.

3) You could declare a public variable in a standard module
public lngEventID as long
public lngPatientID as long

Then in the calling form
lngEventID = me.eventID
lngPatientID = me.patienID
docmd.openForm ("newForm")

and in your new form in the on load event
me.eventID = lngEventID

I would probably go with 2.
 
Thank you so much for all your help - database now complete!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top