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

subform to subform communication 1

Status
Not open for further replies.

martinm

IS-IT--Management
Mar 30, 2001
113
0
0
GB
Right, I'm getting the hang of things now, but have been banging my head against anything hard on this one

The current form has a subform showing products, and a few details for each product.

I need to add new functionality to allow each product to have related data from a new table, linked by product code.

Adding a databound subform doesn't work, as it only shows one master (product) record at a time, rather than all of them as it currently does.

So, I've created a new subform and placed on the main form (so that now has 2 subforms, effectively master and detail, but not bound or nested)

I need to be able to pass the product code of the selected master record (which I can get with the on_enter event)and pass to the new subform's filter. I can get the subform from the forms collection, but can't find how to access the filter. (Tried casting but user defined not allowed error).

Or a better way of doing it!!

Thanks.
 
It sounds like you want synchronized subforms. If that is correct, the easiest way to do that is as follows.
Assume subformA and subformB, where subformB is linked to subformA by productID. These can both be continous forms. The wizard will not let you do this so you will have to do it manually.

1)put a hidden textbox on the main form. Call it txtBxLink.
2) on subformA on current event. Something like
me.parent.txtBxLink = me.productID
3)Bound subformB to txtBxLink
linkMasterFields:[txtBxLink]
linkChildField:[productID_fk]

when a record changes in subformA it updates the value in the txtBxLink. SubformB automatically filters and synchs to the value in the hidden text box.
See demo
 
That sounds exactly what I need thanks.

Got 1 and 2 working (textbox contents change), but can't find where to bind the fields. I'm sure I've seen it somewhere, but not when needed....
 
This is done in the subform control. LinkMaster and LinkChildfields. The subform control has a form object inside it. You need to click on the outside and ensure you have the control not the form inside.
 
Cheers - won't let me do it.

'Can't build a link between unbound forms'

When setting the child or master value.
 
OK, found the answer in


Can just enter the values without using the builder.

All works great.


Finally :) I need to make the layout of sfb the same as sfa. I have done this in the sf design, but when run, it changes to a grid.

access1.jpg





I may change the format of the db table, but currently only 1 row will be in sfb (lower one in the piccy). I want to hide the navigator, and make the layout 'non-grid' as sf1.
 
I said this in my first post
These can both be continous forms. The wizard will not let you do this so you will have to do it manually.

you have the default view of the subform set to "datasheet". Change to continous form and set the navigation buttons to false.
 
Nearly there... sfb has now been created in 'design mode' rather than using the wizard. As such I have control over the layout.

Only remaining problem is the removal of the navigator (apart from anything else, must not be able to add new records other than one per master record)
 
Found the navigation buttons property!

Just need to poke around and add an 'add new record' button and I can get on with the coce (it's the form stuff I find tricky, being a Delphi programmer)

Thanks for your help folks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top