472,352 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Screen.Active Identifying Form,SubForm,Control Names

I am using the Shortcut Menu Bar property of many combobox controls to
execute a single shared custom function.

When the function executes, I need it to immediately identify the
following items:
MainFormName, SubFormControlName (if this is a subform), and the
ComboBox Control Name that launched the event.

The following code seems to work, but I have my doubt. I am
particulary concerned about the subForm control identity. If the
function is launched from the Mainform instead of a subform, then
Line2 just displays the combobox control on the mainform, since no
subform control exists from that perspective.
So, assuming the code below is approaching this whole thing properly,
I would probably identify a subform when the controlnames for the last
two lines of code differ?

1-MsgBox Screen.ActiveForm.Name 'MainForm Name
2-MsgBox Screen.ActiveForm.ActiveControl.Name 'SubForm Control Name
3-MsgBox Screen.ActiveControl.Name 'Active Control name

Am I on the pursuing the properly ???

Thanks
Greg

Feb 15 '07 #1
3 10141
On Feb 15, 11:55 am, "ApexD...@gmail.com" <ApexD...@gmail.comwrote:
I am using the Shortcut Menu Bar property of many combobox controls to
execute a single shared custom function.

When the function executes, I need it to immediately identify the
following items:
MainFormName, SubFormControlName (if this is a subform), and the
ComboBox Control Name that launched the event.

The following code seems to work, but I have my doubt. I am
particulary concerned about the subForm control identity. If the
function is launched from the Mainform instead of a subform, then
Line2 just displays the combobox control on the mainform, since no
subform control exists from that perspective.
So, assuming the code below is approaching this whole thing properly,
I would probably identify a subform when the controlnames for the last
two lines of code differ?

1-MsgBox Screen.ActiveForm.Name 'MainForm Name
2-MsgBox Screen.ActiveForm.ActiveControl.Name 'SubForm Control Name
3-MsgBox Screen.ActiveControl.Name 'Active Control name

Am I on the pursuing the properly ???

Thanks
Greg

Have you tried climbing the object tree in reverse?
ActiveControl.Parent.Parent and so forth.
I would imagine you'd trap for an error when there are no more parent
objects, or check each iteration to see if it's the one you want.
Feb 15 '07 #2
Public Function fcnYourProc(ParamArray Elements()) As String
Dim i As Integer
For i = 0 To Ubound(Elements)
Debug.print Elements(i)
Next
End Function

Private Sub Combofrm1_Click()
Call fcnYourProc("Combofrm1", "MainForm", "FirstSubform")
End Sub

Private Sub Combofrm2_Click()
Call fcnYourProc("Combofrm2", "2ndForm", "2ndSubform", "text2")
End Sub
In your function you can declare a ParamArray argument that will take a
variable number of elements - you can pass 1 arg or multiple args as
show in the example above. The first sample passes 3 args, the 2nd
sample passes 4 args. So In each control that calls this function you
can hardcode the items you want the function to take and do stuff with.
You can even pass an array to ParamArray.
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Feb 15 '07 #3
Thanks guys!
I climbed the Object tree in reverse.

Greg

Feb 16 '07 #4

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

Similar topics

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...
10
by: Sally | last post by:
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? ...
3
by: Simone | last post by:
Hi All, I have a Find Record button setup in most of my forms in order to find a specific customer's details. I have just noticed today though...
1
by: cwessel | last post by:
I have growers with multiple orchards and blocks in my database. When a query is created, the grower name is repeated for each orchard under that...
6
by: dhowell | last post by:
I have a "form" and "subform" where I would like a calculated control on the form which sums the values of a datasheet column of the subform....
6
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can...
5
by: Ron | last post by:
Hi All, I've got a form called frmCust that has a subform on it called sfrmBalance. sfrmBalance's control source is a query called...
4
by: crystal | last post by:
I've checked the threads but haven't been able to come up with a solution to my issue. Help...... I have a simple form based on a table. Within...
1
by: veteranwebdesign | last post by:
Hello, I have a main form. I want forms to open in a subform control box. What is the code for the option group to open the subforms in the...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
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...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
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...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
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....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.