473,383 Members | 1,877 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,383 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 19299
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.