473,396 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
5 6632
I believe it is mainform!subform_with_spaces

Nov 13 '05 #2
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
I was trying something like this:

Me.Invoice_Subform.Form.btnAddRecord_Click

But, alas, it is not working.

Nov 13 '05 #4
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have...
2
by: Lyn | last post by:
Hi, I am working on a genealogy project in which I have two tables: Person -- one record for each person in the family. Each record has a unique Autonum field (IDPerson). Partnerships -- one...
12
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course,...
3
by: Hans Karman | last post by:
I have a form (giving details of a person) and a subform (giving details of the person's assets). A search in the form for a particular name using the Find dialog box finds the wanted person. The...
7
by: Frank Maxey | last post by:
I am fairly new to VB.Net and am having a curious problem. I have an entry dialog form called from a main form. The calling form needs to check the DialogResult field for an OK response. In...
8
by: koorb | last post by:
I am starting a program from a module with the Sub main procedure and I want it to display two forms for the program's interface, but when I run the program both forms just open and then program...
4
by: joanWilder | last post by:
Hello. I am using MS Access 97 at work and trying to do the following... I have a main form which has several combo boxes, 2 buttons (search and refresh) and an unbound subform on it. This form...
2
by: emc_cos | last post by:
I have a very nice parent child relationship happening between a main form and 8 subforms. The main form is the data entry point for a table that holds textual data like names, notes and the...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.