Is the calling Form name or the event handler's sub name available in called module? I need it in order to determine the form's name as in [Forms]!someformname!some control.
Rich
Is the calling Form name or the event handler's sub name available in called module? I need it in order to determine the form's name as in [Forms]!someformname!some control.
Rich
In the module behind the form, you would use "Me.Name"
In a standard module, I would pass the form name as an argument.
The subroutine in a standard module would be:Code:Call DoSomething(Me.Name)
(Could also be a Function)Code:Sub DoSomething(FName as String) Msgbox FName End Sub
not quite sure what you are asking - the form name can be used with me.name
alternatively, if a sub or function in a form is declared as public, and the form is open at the time you would call it from another module like this:
if you look in the vba window navigation you will see how the class names for forms are written - Form_myformname
and in a form module how (for example) a double click event is written - mycontrol_DblClick(Cancel As Integer)
so put it together as
Form_myformname.controlname.sub.mycontrol_DblClick (False)
Note that you cannot build this dynamically
Thanks folks, I found the solution:not quite sure what you are asking - the form name can be used with me.name
alternatively, if a sub or function in a form is declared as public, and the form is open at the time you would call it from another module like this:
if you look in the vba window navigation you will see how the class names for forms are written - Form_myformname
and in a form module how (for example) a double click event is written - mycontrol_DblClick(Cancel As Integer)
so put it together as
Form_myformname.controlname.sub.mycontrol_DblClick (False)
Note that you cannot build this dynamically
Screen.ActiveForm is the form that was active when the standard module was called.
Rich
I'd be curious if this is reliable if you have background forms with timers running. If your code is always on user interaction, you're probably safe regardless. Just be cautious until verified. Sounds suspiciously like "form on top".
Thanks. Ill keep an eye on it.
also be aware that if you are in a subform, screen.activeform refers to the main form
Appreciate your thinking on the matter. It is a main form, though.