By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

Load Subforms Dynamically?

P: n/a
Hello,
I have an Access 2000 ADP main form called frmAD_OpeningForm that
needs to support several possible sub forms.

The subform that should appear would be based on the combined bound
values of two combo boxes that are located in the form header of the
main form. The way I have the combo boxes set up in the main form is
to have the user make a selection in each combo box, then click a
button named ‘Set' (and labeled ‘Set') to make the correct subform
appear. These subforms would appear in the Detail section of the main
form.

When the form initially opens, there is a label in the detail section
(Label15) where the subform would go. This label text basically tells
the user to make a selection from both combo boxes, then click ‘Set'
to see a test. This label should not be visible when there is a
subform in the detail section.

I imagine the logic for what I am trying to do would go something like
this:

On Set_Click
Set frmAD_OpeningForm!Label15.Visible = No
IF (When)
[Forms]![frmAD_OpeningForm]![Combo2]='HMKRL6' And
[Forms]![frmAD_OpeningForm]![Combo4]='00'
THEN
SETVALUE: ITEM: [Forms]![frmAD_OpeningForm]![frmBogusSubForm].[SourceObject]
EXPRESSION: [frm0HMKRL6sub2]
ELSE
IF (Other Combo2 Combo4 Combination)
THEN
SETVALUE : ITEM: (Same subform Source Object (???))
EXREPSSSION: (the subform per the Combo2 and Combo4 combination)
ELSE (evaluate 100+ possible combinations of Combo2 and Combo4 and
show the appropriate subforms)

While the user is in the main form, if changes are made to either
combo2 or combo4, and the user clicks the ‘Set' button, the current
subform would need to be ‘removed' and the new one ‘loaded' if the
combination of the combo boxes would represent a different subform.

When the main form is closed, all subforms would need to be ‘unloaded'
and frmAD_OpeningForm!Label15.Visible = Yes.

I have tried similar logic in a macro to evaluate one possible
combination of Combo2 and Combo4 and assigned it to the On Click event
of the ‘Set' button, but when I tried it, I got the following
message:

The object doesn't contain the Automation object "frmOHMKRL6sub2".
You tired to run a Visual Basic procedure to set a property or method
for an object. However, the component doesn't make the property or
method available for Automation operations.
Check the component's documentation for information on the properties
and methods it makes available for Automation operations.

I think that this means that I can't perform a SET VALUE action on the
Source Object property of a subform. After I click okay on this
message, an ‘Action Failed' dialog box for the macro appears. The
macro does not run, and the frm0HMKRL6sub2 subform does not ‘load'
into the detail section of the main form.

What could I set up to make this work?

Thank you for your help!

CSDunn
Nov 12 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.