469,275 Members | 1,304 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Return Name Of Subform Control

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
Nov 13 '05 #1
3 2249
"Melissa" <ms****@notmyemail.com> wrote in message
news:RW*****************@newsread3.news.pas.earthl ink.net
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.


I believe that in the subform control's Enter event,

Me.ActiveControl.Name

will give you the name of the subform control.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
Nov 13 '05 #2
It is not clear what you are trying to do. But if you want to set the
name of a subform to a variable when you enter that subform - just do
this: Create a module level variable in the main form

-----------------------------------------
Dim subFrmName As String

Private Sub Form3_Enter()
subFrmName = Form3
End Sub
==========================================

or if you want to pass the actual subform to a function when you enter
the subform, do this:

==========================================
Private Sub Form3_Enter()
Me.Form3!Text0 = "testingjhgkjhg"
End Sub
------------------------------------------

where Text0 is a textbox in Form3. What does MyFunction do? What kind
of data does it return?
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #3
Ciao Melissa,

Following what Dick Goldbar wrote, I would add the following:

Where will MyFunction() be?

1. If it is in the form's module then MyFunction() could be:

Public Function MyFunction()

MsgBox "I'm in subform: " & Me.ActiveControl.Name
' your code etc.

End Function

The 'On enter' event property for each subform control should be:
=MyFunction()

2. If it is in a global module then MyFunction() should be:

Public Function MyFunction(rfrm As Form)

MsgBox "I'm in subform: " & rfrm.ActiveControl.Name
' your code etc.

End Function

The 'On enter' event property for each subform control should be:
=MyFunction([Form])

Cheers,

Mike Watson
Connecting Software
via Lodovico il Moro 87
20143 Milano, Italy

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by maxjake via AccessMonster.com | last post: by
6 posts views Thread by DMUM via AccessMonster.com | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.