473,326 Members | 2,588 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,326 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 10319
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 for the subform control is, of course,...
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? MsgBox "MySubform is in " & < ???? > Thanks, ...
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 that this search will only find the customer if it...
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 grower. When I create a form, I have the...
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. (datasheet on subform may have a variable number of...
6
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after...
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 qryTrans4CustBal. sfrmBalance has one field on it 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 the form is a subform that is also, through a Q,...
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 control box. I didn't create subforms, I created...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.