UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> From Subform Module Get Name Of Subform Control, Access 2016    
 
   
Pilotwings_64
post Sep 19 2019, 05:08 PM
Post#1



Posts: 281
Joined: 20-August 10



Is there any way from a subform's module to get the name of it's subform control on the main form?

I sometimes use the same subform multiple times in subform controls on the same form. So cycling through the parent form's controls and looking for one where .SourceObject matches my subform name will not work.

Maybe if there was a subform instance name or something like that I could reference...

All help will be greatly appreciated smile.gif

Go to the top of the page
 
June7
post Sep 19 2019, 06:11 PM
Post#2



Posts: 953
Joined: 25-January 16



Not sure what you are trying to accomplish but maybe this will help:

Forms!Main.ActiveControl.Name

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
Phil_cattivocara...
post Sep 20 2019, 02:52 AM
Post#3



Posts: 367
Joined: 2-April 18



QUOTE
Is there any way from a subform's module to get the name of it's subform control on the main form?
The only way I have found in my tests (for this thread only, I never did it before) is to use hWnd Property.From the subform you find its hWnd property. Then you go to the main form (even remaing in the subform, using its' Parent property), you loop through each control and if its .Form.hWnd property is the same you have found the container control.
Now you have to choose the better way to loop through controls. Only containers have .Form.hWnd property, so if you do such a thing
CODE
For each ctl in Controls
      Debug.Print clt.Form.hWnd 'this only an example
Next
at the first label or textbox (or any other control other then a container) you will have an error.
Or you ignore errors or you previously check if it is a container with
CODE
If TypeOf (ctl) is SubForm Then
I hope my explaination is not so foggy
This post has been edited by Phil_cattivocarattere: Sep 20 2019, 02:55 AM

--------------------
Please forgive in advance my horrible English.
Go to the top of the page
 
Pilotwings_64
post Sep 28 2019, 12:31 PM
Post#4



Posts: 281
Joined: 20-August 10



Thank you Phil!

That worked like a charm.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    11th November 2019 - 06:23 PM