473,786 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6695
I believe it is mainform!subfor m_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_Subf orm.Form.btnAdd Record_Click

But, alas, it is not working.

Nov 13 '05 #4
cw****@psu.edu wrote:
I was trying something like this:

Me.Invoice_Subf orm.Form.btnAdd Record_Click

But, alas, it is not working.


Should work using the Call keyword, e.g.

Call Invoice_Subform .Form.btnAddRec ord_Click

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

Public Sub btnAddRecord_Cl ick()
...
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_Sub form.Form.btnAd dRecord_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
2446
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 a form, that has several tabs. On one tab, I have a subform (wr_completion_subform). This subform is bound to a table (wr_completion_table). On the subform, I have a button from which I have added code to email a report of the completion data...
2
2238
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 record for each marriage. Each record has a unique Autonum field (ID), and also contains two fields IDPartnerMale and IDPartnerFemale. Both of the latter fields match records in the Person table via IDPerson.
12
19015
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, frmBrowseNegsSubform. I would like to perform an ascending or descending sort on any of the 7 columns shown in datasheet view in the subform control. I've been unsuccessful. Is there something tricky about sorting in subform controls?
3
1482
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 assets are then updated and the next person's name entered into the Find dialog box, but this fails to find the required name, because the focus is still in the subform. The user thus has to first place the cursor into the form and then execute...
7
2648
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 my button service in the dialog form, I have: Private Sub btnSave_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnSave.Click
8
6462
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 closes. Dim FORM1 As New Form1 Dim FORM2 As New form2 Sub main() FORM1.Show() FORM2.Show()
4
6180
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 acts like a search screen, searching thru a bunch of records using the combo selections as filters. The search runs when the user makes some selections and then clicks the search button. I decided to use the unbound subform for performance...
2
5218
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 like. It also holds the primary key which is an alpha-numeric file designation. The subforms are the data entry point for another table that holds numeric values for time spent on tasks.
21
5104
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 form, the code errors out at the 2nd line. The error number is 13 and the description is "Type mismatch". Both controls are memo fields. I suspect that "Screen.ActiveControl.Parent" is not referencing the form as intended. Thanks for any help,...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.