Form Wont Hide

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I'm trying to hide a form based on a Select Case.
The form refuses to hide. I tried it with On Open and On Load.
If I put the hide code on a command button and it works.
Any help appreciated.

Private Sub Form_Open(Cancel As Integer)
Dim blRet As Boolean
Dim lngColor As Long
lngColor = RGB(255, 255, 255)
blRet = RestoreMDIBackGroundImage(lngColor)
Select Case Me.TxtPause
Case 0
Forms!EasyStart.Visible = True
Case 1
Forms!EasyStart.Visible = False
DoCmd.OpenForm "Easy1"
Case 2
Forms!EasyStart.Visible = False
DoCmd.OpenForm "Easy2"
Case 3
Forms!EasyStart.Visible = False
DoCmd.OpenForm "Easy3"
End Select
End Sub

Thanks
DS
 
DS,

Forms don't have a Visible property, but you could either minimize the form
or close it:

DoCmd.Minimize

OR

DoCmd.Close

Sprinks
 
Forms actually do have a visible property.

I've tried .Visible=False in the form open event and it seems to work. Is
this code in the EasyStart form? Could there be anything else going on that's
preventing this? What happens if you comment out your API call?

Barry
 
Dear MikeCampy, Barry, Sprinks..


Barry, I don't see a "Visible" property on the Form's property sheet... Am I
missing something?

Mike, I see you know how to set a form visible or not using code, and you
*can* do it from a command button on a form. What you *can't* do is to use
is the Open event of the form itself to make the form invisible. I once ran
into this problem, and received assistance from Dirk Goldgar (MVP), who
wrote:

partial quote...

Now I understand what the problem is. Hiding or keeping the focus from
a form when it is first opened is actually rather difficult (unless it's
opened hidden). It's harder than it should be, because Access assumes
that you opened the form because you want to show it. TTBOMK (and I've
tinkered with this before), there's no event that fires immediately upon
opening that will keep the form from becoming visible and getting the
focus. However, you can use the Timer event to hide the form or set the
focus to another form.

end of partial quote....

HTH
Fred Boer
 
Fred et al,

Just because the property isn't available on the property sheet doesn't mean
it doesn't exist.

When I tried this before, I went from design view to normal view. For some
reason, when opening it that way, it does work, but I see now that when you
open it directly, it doesn't.

Another suggestion:
If the form is opened from a menu or switchboard form of some kind, you
could run your case statement before opening the form and then use the
WindowMode parameter of the OpenForm method to open it hidden.

Barry
 
Dear Barry:

Yes, obviously the property exists or we couldn't manipulate it in code!
Don't know what I was thinking when I wrote that line! Doh!

Cheers,
Fred
 
Fred said:
Dear Barry:

Yes, obviously the property exists or we couldn't manipulate it in code!
Don't know what I was thinking when I wrote that line! Doh!

Cheers,
Fred
Who would of thought that this would be so difficult. Here's what I
figured out. I open the form. I refer to the Select Case, the form
opens but it's so brief that you can't see it, then the correct form
opens. I bookmark the form buy putting an SQL statement on the close
button of the last easy form that is open so when the EasyStar form
opens it reads the TxtPause box and opens the last form that was opened.
It works, and it prevents me from having to keep the first form open.
Thanks for the info.
DS
 
Back
Top