PC Review


Reply
Thread Tools Rate Thread

Check if Form is Visible ?

 
 
Dave Ruhl
Guest
Posts: n/a
 
      2nd Feb 2004
How can I check to see if a form is visible from another
form ? I've tried the following code, which works fine
if the form IS visible, but I get an error if it isn't.
I realize I could handle the error and get around it, but
there should be a simpler way. Thanks in advance!

If Forms!frmMyForm.Visible = True Then
' do whatever....
Else
' do whatever else....
Endif
 
Reply With Quote
 
 
 
 
Bruce M. Thompson
Guest
Posts: n/a
 
      2nd Feb 2004
> How can I check to see if a form is visible from another
> form ? I've tried the following code, which works fine
> if the form IS visible, but I get an error if it isn't.
> I realize I could handle the error and get around it, but
> there should be a simpler way. Thanks in advance!
>
> If Forms!frmMyForm.Visible = True Then
> ' do whatever....
> Else
> ' do whatever else....
> Endif


When the error is generated, is the form open, but just invisible, or just not
open? If you want to see if the form is open, try this instead:

'***
Dim IsVisible As Boolean

If IsLoaded(strFormName) Then
IsVisible = Forms(strFormName).Visible
Else 'Form isn't open, so it's not visible, either
IsVisible = False
End If
'***

Copy and paste this function to a standard module (a global module, not a module
behind a form or report):

'***FUNCTION START
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const conObjStateClosed = 0
Const conDesignView = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed
Then
If Forms(strFormName).CurrentView <> conDesignView Then
IsLoaded = True
End If
End If

End Function
'***FUNCTION END

--
Bruce M. Thompson, Microsoft Access MVP
(E-Mail Removed) (See the Access FAQ at http://www.mvps.org/access)
>> NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<


 
Reply With Quote
 
Dave Ruhl
Guest
Posts: n/a
 
      2nd Feb 2004
Thanks! That's just what I was looking for!

>-----Original Message-----
>> How can I check to see if a form is visible from

another
>> form ? I've tried the following code, which works fine
>> if the form IS visible, but I get an error if it isn't.
>> I realize I could handle the error and get around it,

but
>> there should be a simpler way. Thanks in advance!
>>
>> If Forms!frmMyForm.Visible = True Then
>> ' do whatever....
>> Else
>> ' do whatever else....
>> Endif

>
>When the error is generated, is the form open, but just

invisible, or just not
>open? If you want to see if the form is open, try this

instead:
>
>'***
> Dim IsVisible As Boolean
>
> If IsLoaded(strFormName) Then
> IsVisible = Forms(strFormName).Visible
> Else 'Form isn't open, so it's not visible, either
> IsVisible = False
> End If
>'***
>
>Copy and paste this function to a standard module (a

global module, not a module
>behind a form or report):
>
>'***FUNCTION START
>Function IsLoaded(ByVal strFormName As String) As Boolean
> ' Returns True if the specified form is open in Form

view or Datasheet view.
>
> Const conObjStateClosed = 0
> Const conDesignView = 0
>
> If SysCmd(acSysCmdGetObjectState, acForm,

strFormName) <> conObjStateClosed
>Then
> If Forms(strFormName).CurrentView <>

conDesignView Then
> IsLoaded = True
> End If
> End If
>
>End Function
>'***FUNCTION END
>
>--
>Bruce M. Thompson, Microsoft Access MVP
>(E-Mail Removed) (See the Access FAQ at

http://www.mvps.org/access)
>>> NO Email Please. Keep all communications

> within the newsgroups so that all might benefit.<<
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Making A form tab invisible/visible with a check box jaythe0ne@hotmail.co.uk Microsoft Access Forms 2 15th Aug 2009 09:14 AM
Tabs visible, not visible on form load Ryis Microsoft Access Forms 2 31st Oct 2008 06:57 PM
Check if a form or control is visible in Desktop (to the user) =?Utf-8?B?c2Ftbm9zcGFtQG5vc3BhbS5ub3NwYW0=?= Microsoft Dot NET Framework Forms 3 22nd Feb 2006 09:11 AM
Howto check if form is visible in code H. den Breejen Microsoft Dot NET Framework Forms 0 10th Dec 2003 10:55 AM
How do I get lines in a form to be visible/invisible based on check box? Fatz Microsoft Access Forms 2 29th Jul 2003 06:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:29 AM.