473,691 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get Name Of Subform Control

When I click on a control in a subform, what is the syntax to return the
name of the subform control on the main form that contains the subform?

MsgBox "MySubform is in " & < ???? >

Thanks,

Sally
Nov 13 '05 #1
10 19351
On Sat, 15 Jan 2005 20:18:05 GMT, "Sally" <sm*****@notmye mail.com>
wrote:

mysubformcontro l.Form!mycontro l

mysubformcontro l is the name of the subform control on the parent
form.
With .Form you step into the subform.
mycontrol is the name of the control in the subform.

-Tom.

When I click on a control in a subform, what is the syntax to return the
name of the subform control on the main form that contains the subform?

MsgBox "MySubform is in " & < ???? >

Thanks,

Sally


Nov 13 '05 #2
Sally wrote:
When I click on a control in a subform, what is the syntax to return
the name of the subform control on the main form that contains the
subform?

MsgBox "MySubform is in " & < ???? >


A handy reference for this can be found at
http://www.mvps.org/access/forms/frm0031.htm

--
Joan Wild
Microsoft Access MVP
Nov 13 '05 #3
Hi Sally

Because you are clicking on a control in the subform, you can guarantee that
the subform has the focus, and therefore its container control is the active
control on the main form. Therefore, you can get it like this:
Me.Parent.Activ eControl.Name
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Sally" <sm*****@notmye mail.com> wrote in message
news:1U******** *********@newsr ead3.news.pas.e arthlink.net...
When I click on a control in a subform, what is the syntax to return the
name of the subform control on the main form that contains the subform?

MsgBox "MySubform is in " & < ???? >

Thanks,

Sally

Nov 13 '05 #4
Joan,

Thank you for responding! I want to get the name of the subform control on
the main form. Don't see anything for that at your URL.

Sally
"Joan Wild" <jw***@nospamty enet.com> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
Sally wrote:
When I click on a control in a subform, what is the syntax to return
the name of the subform control on the main form that contains the
subform?

MsgBox "MySubform is in " & < ???? >


A handy reference for this can be found at
http://www.mvps.org/access/forms/frm0031.htm

--
Joan Wild
Microsoft Access MVP

Nov 13 '05 #5
Thank you for responding! I'm looking for code that returns
"mysubformcontr ol".

Sally

"Tom van Stiphout" <no************ *@cox.net> wrote in message
news:os******** *************** *********@4ax.c om...
On Sat, 15 Jan 2005 20:18:05 GMT, "Sally" <sm*****@notmye mail.com>
wrote:

mysubformcontro l.Form!mycontro l

mysubformcontro l is the name of the subform control on the parent
form.
With .Form you step into the subform.
mycontrol is the name of the control in the subform.

-Tom.

When I click on a control in a subform, what is the syntax to return the
name of the subform control on the main form that contains the subform?

MsgBox "MySubform is in " & < ???? >

Thanks,

Sally

Nov 13 '05 #6
Graham,

Thanks for responding! That looks just like what I am looking for.
Appreciate it.

Sally
"Graham Mandeno" <Gr************ @nomail.please> wrote in message
news:u0******** ******@tk2msftn gp13.phx.gbl...
Hi Sally

Because you are clicking on a control in the subform, you can guarantee that the subform has the focus, and therefore its container control is the active control on the main form. Therefore, you can get it like this:
Me.Parent.Activ eControl.Name
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Sally" <sm*****@notmye mail.com> wrote in message
news:1U******** *********@newsr ead3.news.pas.e arthlink.net...
When I click on a control in a subform, what is the syntax to return the
name of the subform control on the main form that contains the subform?

MsgBox "MySubform is in " & < ???? >

Thanks,

Sally


Nov 13 '05 #7

"Sally" <sm*****@notmye mail.com> wrote
Thanks for responding! That looks just
like what I am looking for.


Even simpler, for code executing in the module of the Form embedded in the
Subform Control... because the Subform has focus, Me.Name will return its
name.

Nov 13 '05 #8
On Sun, 16 Jan 2005 03:12:39 GMT, "Larry Linson" <bo*****@localh ost.not>
wrote:

"Sally" <sm*****@notmye mail.com> wrote
Thanks for responding! That looks just
like what I am looking for.


Even simpler, for code executing in the module of the Form embedded in the
Subform Control... because the Subform has focus, Me.Name will return its
name.


Actually, Me is the name of the object containing the code that is running and
has nothing to do with the Active Control. "Me" will, however, always return
a reference to the subform object. It will not return a reference to the
suform control that -contains- that form.

It is possible to incontrovertibl y determine the subform control on the parent
form that contains a given subform if you have a reference to the subform, and
it doesn't depend on active controls, etc. The way you do it is to cycle
through all the controls on the parent form, and for each subform control
found, compare the subform's .Form.Hwnd property to the original subform's
..Hwnd property. If 2 form references have the same .Hwnd property value, the
references are to the same form instance.
Nov 13 '05 #9
Hi Sally,

I think you'll have to iterate the control collection for the form testing
each control for TypeOf. When you find a subform get its name. From Acc97
Help:

Use If TypeOf construct to determine whether the Control passed into a
procedure is a text box.

Sub ControlProcesso r(MyControl As Control)
If TypeOf MyControl Is CommandButton Then
Debug.Print "You passed in a " & TypeName(MyCont rol)
ElseIf TypeOf MyControl Is CheckBox Then
Debug.Print "You passed in a " & TypeName(MyCont rol)
ElseIf TypeOf MyControl Is TextBox Then
Debug.Print "You passed in a " & TypeName(MyCont rol)
End If
End Sub

HTH
--
-Larry-
--

"Sally" <sm*****@notmye mail.com> wrote in message
news:7Q******** ********@newsre ad1.news.pas.ea rthlink.net...
Joan,

Thank you for responding! I want to get the name of the subform control on
the main form. Don't see anything for that at your URL.

Sally
"Joan Wild" <jw***@nospamty enet.com> wrote in message
news:ez******** *****@tk2msftng p13.phx.gbl...
Sally wrote:
When I click on a control in a subform, what is the syntax to return
the name of the subform control on the main form that contains the
subform?

MsgBox "MySubform is in " & < ???? >


A handy reference for this can be found at
http://www.mvps.org/access/forms/frm0031.htm

--
Joan Wild
Microsoft Access MVP


Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
10234
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
12
19007
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
4138
by: Joshua Ammann | last post by:
Hi, (Using Access 2000) I have two tables, similar to Customers and Orders. (Not an exact parallel, but works for this example.) On a form showing customer data, there is a tab control. One of the tabs has a subform showing order data (in datasheet view). On the same tab there is an unbound textbox (next to the datasheet). I placed a
3
2470
by: Melissa | last post by:
I have forty-two small subforms on a form. I need help with the code that will return the name of the subform control when I click on any subform control. I know how to select all the subform controls at once and then enter =MyFunction in the Enter event; I need the code for MyFunction. Thanks, Melissa
1
2320
by: tdmailbox | last post by:
I have the statment below that turns off allow edits so thatwhen I run the commend acCmdFind I only see the find menu rather then find and replace. The search button is on the parent form, however there is a subform too and when I am in the subform this procedure doesnt work. How can I have modify Me.AllowEdits=false to point to both the parent and the subform by name? the parents form name is frm_pe and the subforms name is...
2
1539
by: pietlinden | last post by:
I have a stupid question (so finish swallowing now... I don't want to be accused of any beverage-related mishaps). I have a form with several subforms, with each subform on a separate tab. I'm trying to loop through the subforms so that I can set the caption of the tabcontrol page to something like <SubName> (recordcount) Okay, now the two dumb questions... 1. why do these subforms think they're called "tbl..." when I saved the
2
1591
by: maxjake via AccessMonster.com | last post by:
Hi I have a subform with one text field. I want to show just the text, NO header, No name etc. I dont know how to remove the name. (The subform is in datasheet view) Thanks Max --
6
5970
by: DMUM via AccessMonster.com | last post by:
Hello I am trying to pass the name of my subform to a function/sub but I can't seem to get it to work. I am using an autokey function (ctrl E) to unlock text boxes on a subform. I have a few forms in the database that will use this function, so I need to be able to tell the code which form to unlock. What I have is as follows: Public Function akeyEdit()
7
12300
by: ApexData | last post by:
I am using the following code in my TabControl to manage subform loads. The code assigns the subForms SourceObject. - Do I also need code to DeAssign the SourceObject when leaving the Tab, I'm thinking the Table will stay open otherwise ??? - Do I also need to use code to Assign the Child&Master Links, or can I just type the names into the subForms Control Property and just depend on the SourceObject to link to Table???
0
8600
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
8535
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9079
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...
1
8793
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
8796
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...
0
7626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6457
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
4553
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1954
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.