Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

vba - Access - How to link dynamically loaded unbounded subforms to main form?

New to access and vba.

I have a bound main form (FormA) with a combobox on it and two unbound subforms (subfrmA & subfrmB). (Both forms are attached to a table however I want them to load onto the main form where I placed an unbound subform as a placeholder)

The combobox has two values “a” and “b.” When a is selected I want subfrm A to load onto Form A. When b is selected I want subfrmB to load onto Form A. — So far I think have this part working

However when I select a record on the main form the associated subforms doesn’t appear. When I try to link the subforms to the main form an error message appears saying I can’t build a link between unbound forms.

The packageID is the link between the main form and subform snd is a hidden field on all forms. Whenever the packageID is automatically updated the psckageID in the subform fields are also updated.

form design view

Case”A”                  
            Me.subfrmAB.SourceObject=“FormA
            Me.packageDetailsID=Me.subfrmAB.packageDetailsID
Case “B”

                                                              
            Me.subfrmAB.SourceObject=“FormB”
            Me.packageDetailsID=Me.subfrmAB.packageDetailsID
question from:https://stackoverflow.com/questions/65924972/access-how-to-link-dynamically-loaded-unbounded-subforms-to-main-form

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

One option is to create a dummy table with one record and bind the subform to that. But you'd have to read and write all the values with code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...