473,558 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Screen.Active Identifying Form,SubForm,Co ntrol 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, SubFormControlN ame (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.ActiveFo rm.Name 'MainForm Name
2-MsgBox Screen.ActiveFo rm.ActiveContro l.Name 'SubForm Control Name
3-MsgBox Screen.ActiveCo ntrol.Name 'Active Control name

Am I on the pursuing the properly ???

Thanks
Greg

Feb 15 '07 #1
3 10369
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, SubFormControlN ame (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.ActiveFo rm.Name 'MainForm Name
2-MsgBox Screen.ActiveFo rm.ActiveContro l.Name 'SubForm Control Name
3-MsgBox Screen.ActiveCo ntrol.Name 'Active Control name

Am I on the pursuing the properly ???

Thanks
Greg

Have you tried climbing the object tree in reverse?
ActiveControl.P arent.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(Par amArray 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("Co mbofrm1", "MainForm", "FirstSubfo rm")
End Sub

Private Sub Combofrm2_Click ()
Call fcnYourProc("Co mbofrm2", "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
18994
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, frmBrowseNegsSubform. I would like to perform an ascending or descending sort on any of the 7 columns shown in datasheet view in the subform control. I've...
10
19336
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, Sally
3
2791
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 already has linked data in the subform. This totally defeats the purpose of my search, which is to find an existing customer's details in order to...
1
1819
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 grower name in the main form and the orchards and blocks in a subform underneath the grower name. The subform shows all the orchards a grower has at one...
6
5876
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 entries) I can't seem to get the calculated control on main form to do what I want...... Is this possible, if so, how? Help!
6
3785
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 you enter data to the first field on the main form (a VIN#), that is not the case. The SubForm control becomes disabled and will not accept the...
5
1845
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 fldTransTotal where the control source is =Sum(). LineTotal is derived from Quantity * Amount in the above query. I have a checkbox called chkActive...
4
8491
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, based on the same table. The code: Private Sub Select_BeforeUpdate(Cancel As Integer) On Error GoTo resetselect_Err
1
3236
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 regular forms, but will create subforms if that is needed for this to work. My main goal is when a user clicks on a menu item and comes to a main
0
7835
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8061
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6183
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5455
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5172
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3602
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1164
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.