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

Problem with calling subform's button click event from the main form

P: n/a
I am trying to call the click event of a button located in a subform
called "Order Subform" from a button in the parent. However, since the
subform was made with the wizard, it contains a space in its name, so
the syntax that I have found for this has not been working. If anyone
knows the syntax for this, I would appreciate it.

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I believe it is mainform!subform_with_spaces

Nov 13 '05 #2

P: n/a
cw****@psu.edu wrote:
I am trying to call the click event of a button located in a subform
called "Order Subform" from a button in the parent. However, since the
subform was made with the wizard, it contains a space in its name, so
the syntax that I have found for this has not been working. If anyone
knows the syntax for this, I would appreciate it.


It would save a lot of ibuprofen if you renamed these things to have no
spaces in.

The person responsible for allowing spaces in table/field/control names
should be taken outside, shot, brought back to life then killed all over
again.
--
[OO=00=OO]
Nov 13 '05 #3

P: n/a
I was trying something like this:

Me.Invoice_Subform.Form.btnAddRecord_Click

But, alas, it is not working.

Nov 13 '05 #4

P: n/a
cw****@psu.edu wrote:
I was trying something like this:

Me.Invoice_Subform.Form.btnAddRecord_Click

But, alas, it is not working.


Should work using the Call keyword, e.g.

Call Invoice_Subform.Form.btnAddRecord_Click

But make sure you made it public so in the subform it says:

Public Sub btnAddRecord_Click()
...
End Sub

--
[OO=00=OO]
Nov 13 '05 #5

P: n/a
On 2 Jun 2005 19:38:29 -0700, cw****@psu.edu wrote:
I was trying something like this:

Me.Invoice_Subform.Form.btnAddRecord_Click

But, alas, it is not working.


First point - by default, event procedures are defined as Private by default,
so they can't be invoked from other modules. You -could- fix that by making
the event procedure public, but ...

Generally, you want code to be as self-descriptive as possible. The main
form's code is not clicking the button on the subform, is it? No, it's
requesting an action that happens to be the same action the button performs.
In that case, it makes more sense to make a new public function with a name
descriptive of what it actually does, and call that both from the click
handler of the button on the subform and from the code on the main form.

If you are making your code self-documenting, most event handlers never end up
doing much directly (regardless of whether something else needs to perform the
same action - yet), they instead call one or a small number of other,
descriptively named procedures that actually do the work.
Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.