Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...The enviroment is simple, natural and efficient. The members are competent, educated and professionals..."

Geography

Where in the world do Tek-Tips members come from?

How can subform know its name in parent form

PeDa (TechnicalUser)
17 Aug 12 10:21
My form "Mainform" contains a number of identical subforms "MySubform" (i.e. they all have the same Source Object). In Mainform their names are Subform1, Subform2, Subform3... How can I, in the code of the subform, determine in which instance of the subform I am working? Me.Name returns "MySubform", and not "Subform1" or whatever.

missinglinq (Programmer)
17 Aug 12 17:08
Not even going to inquire as to why you would need multiple, identical Subforms on a single Main Form! But presumably each iteration of the Subform has a different Caption, i.e. Subform1, Subform2, etc. to identify it to the user. From any given Subform you should be able to use Me.Caption to to identify the exact one currently being used. If you simply Copied & Pasted one Subform several times, you may need to go in and modify each one's Caption Property.

Linq ;0)>

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

PeDa (TechnicalUser)
18 Aug 12 7:57
Thank you, MissingLinq, but perhaps I didn't explain clearly enough. There is only one actual subform, which I include five times in my main form (and don't worry, there is a good reason), so all five instances have the same Caption. However, upon further reflection, the solution is quite simple: put an invisible textbox on the subform, and load this with a different value in each instance at load time.
missinglinq (Programmer)
18 Aug 12 9:17
Sounds like a plan, Stan!

Good luck with your project!

The Missinglinq

Richmond, Virginia

The Devil's in the Details!

MajP (TechnicalUser)
20 Aug 12 10:23

CODE

Public Function getSubFormControl(subfrm As Access.Form) As Access.SubForm
  Dim ctrl As Access.Control
  For Each ctrl In subfrm.Parent.Controls
    'Find if it is a subform control
    If TypeOf ctrl Is Access.SubForm Then
      'See if the form in the subform control is the active subform
      If ctrl.Form Is subfrm Then
        Set getSubFormControl = ctrl
      End If
    End If
  Next ctrl
End Function 

how to call from a subform instance

CODE

Private Sub fldOne_DblClick(Cancel As Integer)
  MsgBox getSubFormControl(Me).Name
End Sub 

Same technique can be used with multiple instances of forms.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close