How to check active form

Before i show or activate the current form, I want to determine whether the customer form already show on screen, If yes I will retrieve the customer # else I set the customer # to blank. My problem is how can I check whether the customer form is show or active ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this:

   If formx.visible=true then
   end if

Be careful... If you have any statements in the form_load event and the form has not been loaded, the event will fire after the form.visible propery is checked...

Otherwise, you can create a public or global variable for each form as BOOLEAN... then set the variable to TRUE when you show the form and FALSE when you hide it... You can then test it anytime...

Substitute the name of your customer form for sFormName.  This suggestion gets around the limitation of the form not being loaded.

Happy hunting!

Dim n As Long
Dim sFormName As String
Dim bFormIsLoaded As Boolean

sFormName = "Form1"

For n = 0 To Forms.Count - 1
    If Forms(n).Name = sFormName Then
        If (Forms(n).Visible) Then
            'form is loaded and visible
            'form is loaded and NOT visible
        End If
        bFormIsLoaded = True
    Else    'do nothing--this is not the form of interest
    End If
Next n

If (Not (bFormIsLoaded)) Then
    'form is NOT loaded
Else: End If
DONOT create an instance of the form customer like(Dim frmCust as New frmCustomer). Just directly load the form. Thats it. For example, consider the following:

 Form Customer's name is 'frmCustomer'

In the appropriate event paste the following code:

Load frmCustomer

With the above code, if the form is loaded for the first time, its normal. If its not loaded the first time (ie)if the menu is clicked when the form is already loaded, the form will be brought to the front with the previously entered details.

Hope you get it right and hope this is what you were looking for!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.