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

subform of a subform 1

Status
Not open for further replies.

swtrader

IS-IT--Management
Dec 23, 2004
182
US
Aceman, I've read your "late binding" info. Am uncertain if it applies -- or, if it does, how to apply it. Others are welcome to help, of course.

the givens:

MainForm (MF)
SubFormAOfMainForm (1)
SubForm1OfSubFormA (2)
SubForm2OfSubFormA (3)

I created MF, 1, and 2 using a wizard and they work fine. I've "inserted" another subform (3) onto MF.

3 is a subform of 1.

I've added a textfield on the mainform that has its control as 1's primary key.

How do I "sync" 3 with 1?

thanks.

 
faq702-5860 is one way. I do it another.

You can put an invisible textbox on the main form. Call it :
txtBxLink

on the on current event of (1) set the value of txtBxLink to some primary key from subform 1 that relates 1 to 3

Now on subform 3 you do a normal "link master fields" "link child fields", but you put the text box name in the the "Master Field
 
How are ya swtrader . . .

Outisde of using [blue]master/Child[/blue] properties to sync ChildForm to ParentForm, [blue]late binding[/blue] is needed if a [blue]childform requires data from a parent.[/blue] If you need to go deeper into this let me know.

When adding/inserting a subform, your first desire (if possible) is linking via [blue]master/Child[/blue] properties. Normally, syncing form with subform follows table relationships, prompting the following question:

Where in the chain of table relationships (relationships window) is [blue]SubForm2OfSubFormA?[/blue]

So the question becomes: Is [blue]MF!PrimaryKey[/blue] a ForeignKey to [blue]SubForm2OfSubFormA?[/blue]

If it is, then make it so. If not let us know . . . or retuen the relationship structure of your tables as far as primary/foreign keys are concerned . . .

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
The relationships....

tblBulkCash (MainForm) pk = BulkCashRcptID
tblCashActivity (Sub 1) pk = CashActivityID; fk is fkBulkCashRcptID
tblMiscContraItems (Sub 3) pk = MiscItemsID; fk is fkCashActivityID

relationships

Mainform 1-to-M with Sub 1
Sub1 1-to-M with Sub 3

I hope this explains it...

Thank you.

 
swtrader . . .

You should have no problem linking the subform3 to subform1 using [blue]Master/Child Link[/blue] properties.

[tt]tblCashActivity (Sub 1) pk = [purple]CashActivityID[/purple]; fk is fkBulkCashRcptID
tblMiscContraItems (Sub 3) pk = MiscItemsID; fk is [purple]fkCashActivityID[/purple][/tt]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Okay -- "Uncle" //

I thought I could figure this out. I can't. Aceman, will you please add more detail?

I know how to get to the Master/Child link properties but I don't know what goes where or what the OnCurrent event of the "parent" form should have in it.

Thanks.
 
I believe that AceMan is assuming that subform 3 is nested in subform 1, I was assuming that subform 3 lies on the mainform and is a synchronized form with subform 1.

If it is nested then you should be able to simply do what Ace Man suggests and you do not need to do anything with the on current event.

If it is the latter then you can synchronize the subforms using the link I posted or as I suggested.

Which on is it? Show us what you have done so far.
 
MajP / I think I've confused the issue. Yes; 3 is "on" MF. I'm trying to sync 3 with 1 (which is a nested subform of MF).

I've put a textbox ("TEXT22") on MF and set it to show the pk from 1. I'm stuck on the next step -- what the specific linkmasterfields and linkchildfields should have.

Thanks for your help and your patience. frustrating on this end.
 
Ok. Subform 1 and Subfrm 3 are both on the main form. So these forms are synchronized not nested.

If interested look at the FAQ. It is a different approach then how I synchronize forms. The nice thing about synched forms is that you can synch continous forms, and synch as many as you want. You can only nest 3 deep ( and I personally find them to be difficult as a user interface)

So now on the mainform you have txt22. Lets give it a better name
txtLink
Leave it visible for now

In subform 1 do something like

Private Sub Form_Current()
Me.Parent.txtLink = Me.CashActivityID
End Sub

Pick a record and see if the value in txtLink changes to the correct ID.

If that works then on subform 3 set up the child master relations.

in the Master field use txtLink like
[txtLink]

In the child field use the fk like normal
fkCashActivityID
 
PERFECT! Thanks, MajP, for the detail. And for your usual kind contribution, AceMan.

swtrader
-- If you don't know where you're going, you'll always know when you're not there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top