472,371 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 18968
On Sat, 15 Jan 2005 20:18:05 GMT, "Sally" <sm*****@notmyemail.com>
wrote:

mysubformcontrol.Form!mycontrol

mysubformcontrol 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.ActiveControl.Name
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Sally" <sm*****@notmyemail.com> wrote in message
news:1U*****************@newsread3.news.pas.earthl ink.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***@nospamtyenet.com> wrote in message
news:ez*************@tk2msftngp13.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
"mysubformcontrol".

Sally

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

mysubformcontrol.Form!mycontrol

mysubformcontrol 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**************@tk2msftngp13.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.ActiveControl.Name
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Sally" <sm*****@notmyemail.com> wrote in message
news:1U*****************@newsread3.news.pas.earthl ink.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*****@notmyemail.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*****@localhost.not>
wrote:

"Sally" <sm*****@notmyemail.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 incontrovertibly 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 ControlProcessor(MyControl As Control)
If TypeOf MyControl Is CommandButton Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is CheckBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
ElseIf TypeOf MyControl Is TextBox Then
Debug.Print "You passed in a " & TypeName(MyControl)
End If
End Sub

HTH
--
-Larry-
--

"Sally" <sm*****@notmyemail.com> wrote in message
news:7Q****************@newsread1.news.pas.earthli nk.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***@nospamtyenet.com> wrote in message
news:ez*************@tk2msftngp13.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
Sally wrote:
Graham,

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

Sally


I put this in the OnCurrent event of the subform.
MsgBox "Control Name is " & Me.ActiveControl.Name
MsgBox "Parent is " & Me.Parent.Name
MsgBox "Me is " & Me.Name
Nov 13 '05 #11

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

Similar topics

25
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...
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: 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...
3
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...
1
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,...
2
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...
2
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
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...
7
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.