how to use a condition in a macro to determine the current object.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to run a macro to open a form, but the subform is used in several
places. I want to create a condition that looks for which form the macro was
initiated so I can determine how to respond. How do I determin which form
initiated the macro? Is there a [active forms] function?
 
I've got a similar issue. I have a form that opens from either one of two
other forms. On this second form (summary form) the user then clicks on a
command button to initiate a macro. I want this macro to be able to determine
which initial form the user came from (which will still be open in the
background). The summary form is a pop-up.
Could you please give me the exact expression for the condition or the
required VB?

thanks,

Ken Snell said:
Try
Screen.ActiveForm.Name

--

Ken Snell
<MS ACCESS MVP>

Scott said:
I am trying to run a macro to open a form, but the subform is used in several
places. I want to create a condition that looks for which form the macro was
initiated so I can determine how to respond. How do I determin which form
initiated the macro? Is there a [active forms] function?
 
I would handle this differently.

On the popup form, put a hidden textbox; name it 'MyParentForm'.

In the code that opens the popup form, use the OpenArgs argument of the
DoCmd.OpenForm action to pass the name of the calling form:
DoCmd.OpenForm "FormBeingOpened", OpenArgs:=Me.Name

In the Load event of the popup form, put this code:
Private Sub Form_Load()
Me.MyParentForm.Value = Me.OpenArgs
End Sub

Then you can test the value of
Screen.ActiveForm.Controls("MyParentForm").Value

to get the name of the form that called the popup form.

--

Ken Snell
<MS ACCESS MVP>

Caroline said:
I've got a similar issue. I have a form that opens from either one of two
other forms. On this second form (summary form) the user then clicks on a
command button to initiate a macro. I want this macro to be able to
determine
which initial form the user came from (which will still be open in the
background). The summary form is a pop-up.
Could you please give me the exact expression for the condition or the
required VB?

thanks,

Ken Snell said:
Try
Screen.ActiveForm.Name

--

Ken Snell
<MS ACCESS MVP>

Scott said:
I am trying to run a macro to open a form, but the subform is used in several
places. I want to create a condition that looks for which form the
macro was
initiated so I can determine how to respond. How do I determin which
form
initiated the macro? Is there a [active forms] function?
 
Back
Top