Connecting Tech Pros Worldwide Forums | Help | Site Map

Event? to know when form is already open in background

P
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi,

Access 2002. I use DoCmd.OpenForm attached to command buttons to open one
form from another form. All forms are open in dialog mode. When a user tries
to open a form already opened from a form in dialog mode, nothing happens as
expected. I would like to inform the users that the form does not open
because it is already opened in the background. What event do you suggest
using for this? Thank you. P



Dirk Goldgar
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Event? to know when form is already open in background


"P" <P@no_spam.com> wrote in message
news:eS1Ab.9294$aw2.4378426@newssrv26.news.prodigy .com[color=blue]
> Hi,
>
> Access 2002. I use DoCmd.OpenForm attached to command buttons to open
> one form from another form. All forms are open in dialog mode. When a
> user tries to open a form already opened from a form in dialog mode,
> nothing happens as expected. I would like to inform the users that
> the form does not open because it is already opened in the
> background. What event do you suggest using for this? Thank you. P[/color]

There is no event, but you can check before calling DoCmd.OpenForm. In
Access 2000 or later, you can do it like this:

Dim strFormToOpen As String

strFormToOpen = "MyForm"

If CurrentProject.AllForms(strFormName).IsLoaded Then
MsgBox "That form is already open."
Else
DoCmd.OpenForm strFormToOpen, WindowMode:=acDialog
End If

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

(please reply to the newsgroup)


P
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Event? to know when form is already open in background


Thank you Dirk. This helps. P.

"Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in message
news:u6PgD00uDHA.2304@TK2MSFTNGP12.phx.gbl...[color=blue]
> "P" <P@no_spam.com> wrote in message
> news:eS1Ab.9294$aw2.4378426@newssrv26.news.prodigy .com[color=green]
> > Hi,
> >
> > Access 2002. I use DoCmd.OpenForm attached to command buttons to open
> > one form from another form. All forms are open in dialog mode. When a
> > user tries to open a form already opened from a form in dialog mode,
> > nothing happens as expected. I would like to inform the users that
> > the form does not open because it is already opened in the
> > background. What event do you suggest using for this? Thank you. P[/color]
>
> There is no event, but you can check before calling DoCmd.OpenForm. In
> Access 2000 or later, you can do it like this:
>
> Dim strFormToOpen As String
>
> strFormToOpen = "MyForm"
>
> If CurrentProject.AllForms(strFormName).IsLoaded Then
> MsgBox "That form is already open."
> Else
> DoCmd.OpenForm strFormToOpen, WindowMode:=acDialog
> End If
>
> --
> Dirk Goldgar, MS Access MVP
> www.datagnostics.com
>
> (please reply to the newsgroup)
>
>[/color]


Pieter Linden
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Event? to know when form is already open in background


Straight outta the help file....

CurrentProject.AllForms("frmGetHostName").IsLoaded

returns either True or False. How much easier could it get?

So you could create a function or something...

public function IsFormLoaded(byval strFormName as String) as boolean

IsFormLoaded =CurrentProject.AllForms(strFormName).IsLoaded

End Function

If IsFormLoaded("MyForm") Then
...
Else
DoCmd.OpenForm strForm
End If
Closed Thread