Re: How to determine source of opened form



"Brendan Reynolds" <brenreyn@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message news:OCu7lXpSFHA.3552@xxxxxxxxxxxxxxxxxxxx
> To determine whether a given form is open ...
>
> If CurrentProject.AllForms("NameOfFormHere").IsLoaded Then
> 'it's open
> Else
> 'it's not
> End If
>
> Access does not (so far as I am aware) expose any means to identify
> what form or procedure opened the active form, so you'd need to keep
> track of that yourself in some way, for example by passing the name
> of the calling form in the OpenArgs argument of the OpenForm method
> or by using a global variable.

This is true, but you can, in the opened form's Open event, find out
what form is currently active by interrogating Screen.ActiveForm.Name,
which -- if this form can only be opened from another form -- will be
the "calling" form.

I prefer Brendan's approach of passing the name of the calling form via
OpenArgs, because it is insulated from any unexpected loss of focus by
the calling form.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.



Relevant Pages

  • Re: OpenArgs Questions
    ... using the OpenArgs argument of the OpenForm method. ... if you're using the OpenForm method, it is *NOT* a Subform, and the ... What you can do involves code in both the calling form and in the called form. ...
    (microsoft.public.access.forms)
  • Re: Method Item of Object Forms Failed
    ... I have way too many global variables and only today took the time to try ... and understand the OpenArgs argument. ... the line of code experiencing the problem is actually in the subform. ... >technique to pass the name of the calling form to the form that is being ...
    (microsoft.public.access.formscoding)
  • Re: Somehow Openargs became Null
    ... I set Openargs to either a record key or zero (if ... adding a record) in the calling form. ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.formscoding)
  • Re: Opening form with Value in Combo Box from another form
    ... OpenArgs is only available with DoCmd.OpenForm, ... Code for calling form: ... Code for Second form: (frmSelDeptsForAd) ... Set mdb = CurrentDb ...
    (comp.databases.ms-access)
  • Re: Identify calling form
    ... event, the calling form is still the "active form", as far as Access is ... might grab the focus between the time the OpenForm method was called on ... Dirk Goldgar, MS Access MVP ...
    (microsoft.public.access.formscoding)

Loading