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

SubForm Reference Syntax Problem

P: n/a
My popup form can reference the MAINFORM by using either line of the
code shown below:

--------------------------------------------------------------------------------
[Forms]("F-PERS").Controls("cboEduc").Requery

'My reference using hidden text boxes.
[Forms](txtFormName).Controls(txtComboName).Requery
--------------------------------------------------------------------------------

My problem is that my popup form cannot seem to reference my SUBFORM
that is located in a tab of my main form. My subform control is called
F-CREDsub and its source is the form F-CRED.

How would the content of my hidden textbox txtFormName look???
I tried "F-CREDsub" "F-PERS.F-CREDsub" but it does not work?

Thanks
Greg

Feb 13 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
The subform is not open in its own right. It is not part of the Forms
collection, so (as you found) you cannot refer to it directly that way.

You may be able to pass a reference to the combo that needs requerying
instead of trying to give the whole reference. For example, you might add
this to the General Declarations of a standard module:
Dim cbo2Requery As ComboBox

Then before you call your popup:
Set cbo2Requery = Me(txtComboName)

Then in the AfterUpdate event of the popup:
If Not cbo2Requery Is Nothing Then
cbo2Requery.Requery
End If
Set cbo2Requery = Nothing

For general info on how to refer to a control on a subform through the Forms
collection, see:
Referring to Controls on a Subform
at:
http://allenbrowne.com/casu-04.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail.comwrote in message
news:11*********************@p10g2000cwp.googlegro ups.com...
My popup form can reference the MAINFORM by using either line of the
code shown below:

--------------------------------------------------------------------------------
[Forms]("F-PERS").Controls("cboEduc").Requery

'My reference using hidden text boxes.
[Forms](txtFormName).Controls(txtComboName).Requery
--------------------------------------------------------------------------------

My problem is that my popup form cannot seem to reference my SUBFORM
that is located in a tab of my main form. My subform control is called
F-CREDsub and its source is the form F-CRED.

How would the content of my hidden textbox txtFormName look???
I tried "F-CREDsub" "F-PERS.F-CREDsub" but it does not work?

Thanks
Greg
Feb 13 '07 #2

P: n/a
Allen, is that to say that a popup form cannot reference the subform
that originally called it? Then how do you guys refresh a combobox
after its table contents change, having used the popup form method? Is
there another approach?
If its the one you suggested, I really dont understand it, and a
weblink might be helpful. I checked out the Link to "Referring to
Controls on a Subform", and still think my problem somehow has
something to do with syntax?

Thanks As Always

Greg

Feb 13 '07 #3

P: n/a
On Feb 12, 9:11 pm, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
Allen, is that to say that a popup form cannot reference the subform
that originally called it? Then how do you guys refresh a combobox
after its table contents change, having used the popup form method? Is
there another approach?
If its the one you suggested, I really dont understand it, and a
weblink might be helpful. I checked out the Link to "Referring to
Controls on a Subform", and still think my problem somehow has
something to do with syntax?

Thanks As Always

Greg


Usually when I need to access controls on a sub form, I drill down
like this MainForm.SubFormControl.Form.TargetControl.Propert yorMethod
I've not done it through a tab control in a long time so I'm not sure
if you need to pass through the Tabs collection or not.
Feb 13 '07 #4

P: n/a
Your example was:
[Forms](txtFormName).Controls(txtComboName).Requery

That cannot work if txtFormName contains the name of a subform control,
since subforms are not part of the Forms collection. Loop through the forms
and verify for yourself that the subforms are not there:
Dim i As Long
For i = 0 to Forms.Count -1
Debug.Print Forms(i).Name
Next

If you just want to requery a single combo, the public object variable will
do it.

To answer your question, what I actually do is to call a public function
named NotifyCombos() in the AfterUpdtate and AfterDelConfirm of all forms.
The function is completed after the database is built, and it consists of a
massive Select Case statement that handles all the dependencies so that any
open forms are notified of the change.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<Ap******@gmail.comwrote in message
news:11********************@v33g2000cwv.googlegrou ps.com...
Allen, is that to say that a popup form cannot reference the subform
that originally called it? Then how do you guys refresh a combobox
after its table contents change, having used the popup form method? Is
there another approach?
If its the one you suggested, I really dont understand it, and a
weblink might be helpful. I checked out the Link to "Referring to
Controls on a Subform", and still think my problem somehow has
something to do with syntax?

Thanks As Always

Greg
Feb 13 '07 #5

P: n/a
This finally resolved my problem:

Forms("[F-PERS]").Controls("[F-CREDsub]").Form.cboEduc.Requery

ThankYou All
Greg

Feb 14 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.