check form open and bring it to front

  • Thread starter Thread starter iccsi
  • Start date Start date
I

iccsi

I would like to check form open or not, if not then open the form and
bring it to front, if it opens then bring it to front.

I tried to look myform.open, but does not exist.
I just wonder any command to do the task.

Your help is great appreciated,
 
DoCmd.OpenForm does exactly what you ask... look it up in Help. You can
defeat it, if you try, by opening other forms as Modal, or as Popup, or as
Dialog... but with all forms opened "acNormal", it opens the form if not
already open, and sets Focus to it (which brings it to the front); if open,
it just sets Focus (which brings it to the front).

Larry Linson
Microsoft Office Access MVP
 
DoCmd.OpenForm does exactly what you ask... look it up in Help.
You can defeat it, if you try, by opening other forms as Modal, or
as Popup, or as Dialog... but with all forms opened "acNormal", it
opens the form if not already open, and sets Focus to it (which
brings it to the front); if open, it just sets Focus (which brings
it to the front).

Let me second what Larry said -- DoCmd.OpenForm will open it if it's
not open, or bring it to the front if it is (unless, as Larry says,
you've set the properties of the form such that it can't).
 
iccsi said:
I would like to check form open or not, if not then open the form
and bring it to front, if it opens then bring it to front.

I tried to look myform.open, but does not exist.
I just wonder any command to do the task.

I think this kind of thing should do that:

If CurrentProject.AllForms![form name].IsLoaded Then
DoCmd.SelectObject acForm, "form name"
Else
DoCmd.OpenForm "form name"
End If

Be sure to check VBA Help for all the stuff that you are not
already familiar with.

Why would you bother to check, given that DoCmd.OpenForm does the
job without any conditional checking?

(also, note that you left out the period between DoCmd and the
command in your sample code -- I've restored it in the quoted code).
 
Back
Top