Using same subform on different mainform using Parent

  • Thread starter Thread starter Bill R via AccessMonster.com
  • Start date Start date
B

Bill R via AccessMonster.com

I would like to use the same subforms for 2 different mainforms. There are
calculations in fields on the subform that use data from the main forms. I
have found that I can't use the "Parent" reference to get the values. I'm
trying to avoid creating separate queries and subforms because of the
accompanying overhead on maintenenance and development.

Any suggestions?

Bill
 
You can refer to the main form via the subform's Parent property.

If the problem is that the 2 different main forms have different controls,
could you add a (hidden) text box to one of the forms, using the same name
as the other form, so the subform works in both contexts?

If not, you might have to use 2 different subforms, which is less desirable
from a maintenance perspective.
 
Thanks for your response, Allen.

Here's the control source for a control on one of the subforms:

=IIf([Forms]![frmSwaps]![grpPayFixed]=1,[Forms]![frmSwaps]![txtStrike],[Float]
)

What's the correct syntax for using the Parent property in place of the form
references in my control source?

Thanks,

Bill
 
(just trying to get this thing to revert to 'Bill R' as my public name)
 
Presumably this main form is named frmSwaps, and has a control named
grpPayFixed? If so, you can refer to the control from the subform like this:
[Form].[Parent]![grpPayFixed]

Form is a reference to the current form (like Me in code).
The Parent of that form gives you the main form.
And the control on the main form is the same syntax as normal.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

ragtopcaddy via AccessMonster.com said:
Thanks for your response, Allen.

Here's the control source for a control on one of the subforms:

=IIf([Forms]![frmSwaps]![grpPayFixed]=1,[Forms]![frmSwaps]![txtStrike],[Float]
)

What's the correct syntax for using the Parent property in place of the
form
references in my control source?

Thanks,

Bill

Allen said:
You can refer to the main form via the subform's Parent property.

If the problem is that the 2 different main forms have different controls,
could you add a (hidden) text box to one of the forms, using the same name
as the other form, so the subform works in both contexts?

If not, you might have to use 2 different subforms, which is less
desirable
from a maintenance perspective.
 
Thanks a million Allen.

Bill

Allen said:
Presumably this main form is named frmSwaps, and has a control named
grpPayFixed? If so, you can refer to the control from the subform like this:
[Form].[Parent]![grpPayFixed]

Form is a reference to the current form (like Me in code).
The Parent of that form gives you the main form.
And the control on the main form is the same syntax as normal.
Thanks for your response, Allen.
[quoted text clipped - 29 lines]
 
Allen,

There is something wrong with this syntax.
When I write it as follows:

Control Source: =IIf([Form].[Parent]![grpPayFixed]=1,[Form].[Parent]!
[txtStrike],[Float])

I get this error msg:
"Microsoft Access can't find the field 'Forms' referred to in your
expression"

Your assumptions below are correct.

Bill

Allen said:
Presumably this main form is named frmSwaps, and has a control named
grpPayFixed? If so, you can refer to the control from the subform like this:
[Form].[Parent]![grpPayFixed]

Form is a reference to the current form (like Me in code).
The Parent of that form gives you the main form.
And the control on the main form is the same syntax as normal.
Thanks for your response, Allen.
[quoted text clipped - 29 lines]
 
Allen,

Nevermind. After a great deal of frustration, I decided to turn my attention
to another error msg I was getting concerning a control source whose field
name had changed in the underlying table. When I fixed that, the data in the
subform displayed perfectly.

Thanks for you help,

Bill

Allen said:
Presumably this main form is named frmSwaps, and has a control named
grpPayFixed? If so, you can refer to the control from the subform like this:
[Form].[Parent]![grpPayFixed]

Form is a reference to the current form (like Me in code).
The Parent of that form gives you the main form.
And the control on the main form is the same syntax as normal.
Thanks for your response, Allen.
[quoted text clipped - 29 lines]

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
 
Back
Top