PC Review


Reply
Thread Tools Rate Thread

Code, is user form open

 
 
=?Utf-8?B?RXhjZWwgMjAwMyAtIFNQQg==?=
Guest
Posts: n/a
 
      16th Oct 2006
I am trying to find code for indentifying if a user form is open

Thanks

SPB
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
for each frm in Userforms
if lcase(frm.name) = "frmabc" then
' frm is loaded
if frm.visible then
' frm is visible
end if
end if
Next

Obviously if the useform isn't loaded, then it can't be visible.

--
Regards,
Tom Ogilvy


"Excel 2003 - SPB" wrote:

> I am trying to find code for indentifying if a user form is open
>
> Thanks
>
> SPB

 
Reply With Quote
 
=?Utf-8?B?RXhjZWwgMjAwMyAtIFNQQg==?=
Guest
Posts: n/a
 
      16th Oct 2006
More Details
I have two forms (of many) [flightlog & maintenance] and I need to identify
which one is open (only one at a time) then are always visible or closed.

"Tom Ogilvy" wrote:

> for each frm in Userforms
> if lcase(frm.name) = "frmabc" then
> ' frm is loaded
> if frm.visible then
> ' frm is visible
> end if
> end if
> Next
>
> Obviously if the useform isn't loaded, then it can't be visible.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Excel 2003 - SPB" wrote:
>
> > I am trying to find code for indentifying if a user form is open
> >
> > Thanks
> >
> > SPB

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      16th Oct 2006
Play with this:

Sub abc()
Dim frm As Object, frm1 As Object
If UserForms.Count > 0 Then
For Each frm In useforms
Unload frm
Next
End If
If Rnd() < 0.5 Then
Load maintenance
maintenance.Show vbModeless
Else
Load flightlog
flightlog.Show vbModeless
End If


namevis = ""
Set frm1 = Nothing
For Each frm In UserForms
Debug.Print TypeName(frm)
If LCase(frm.Name) = "flightlog" Then
If frm.Visible Then
namevis = "flightlog"
Set frm1 = frm
Exit For
End If
ElseIf LCase(frm.Name) = "maintenance" Then
If frm.Visible Then
namevis = "maintenance"
Set frm1 = frm
Exit For
End If
End If
Next
If Not frm1 Is Nothing Then
MsgBox namevis & " is the open form"
End If
Unload frm1
End Sub

--
Regards,
Tom Ogilvy


"Excel 2003 - SPB" wrote:

> More Details
> I have two forms (of many) [flightlog & maintenance] and I need to identify
> which one is open (only one at a time) then are always visible or closed.
>
> "Tom Ogilvy" wrote:
>
> > for each frm in Userforms
> > if lcase(frm.name) = "frmabc" then
> > ' frm is loaded
> > if frm.visible then
> > ' frm is visible
> > end if
> > end if
> > Next
> >
> > Obviously if the useform isn't loaded, then it can't be visible.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Excel 2003 - SPB" wrote:
> >
> > > I am trying to find code for indentifying if a user form is open
> > >
> > > Thanks
> > >
> > > SPB

 
Reply With Quote
 
=?Utf-8?B?RXhjZWwgMjAwMyAtIFNQQg==?=
Guest
Posts: n/a
 
      16th Oct 2006
Thanks tom
I added another elseif for one other area i had not thought about and all is
good

Thanks
SPB

"Tom Ogilvy" wrote:

> Play with this:
>
> Sub abc()
> Dim frm As Object, frm1 As Object
> If UserForms.Count > 0 Then
> For Each frm In useforms
> Unload frm
> Next
> End If
> If Rnd() < 0.5 Then
> Load maintenance
> maintenance.Show vbModeless
> Else
> Load flightlog
> flightlog.Show vbModeless
> End If
>
>
> namevis = ""
> Set frm1 = Nothing
> For Each frm In UserForms
> Debug.Print TypeName(frm)
> If LCase(frm.Name) = "flightlog" Then
> If frm.Visible Then
> namevis = "flightlog"
> Set frm1 = frm
> Exit For
> End If
> ElseIf LCase(frm.Name) = "maintenance" Then
> If frm.Visible Then
> namevis = "maintenance"
> Set frm1 = frm
> Exit For
> End If
> End If
> Next
> If Not frm1 Is Nothing Then
> MsgBox namevis & " is the open form"
> End If
> Unload frm1
> End Sub
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Excel 2003 - SPB" wrote:
>
> > More Details
> > I have two forms (of many) [flightlog & maintenance] and I need to identify
> > which one is open (only one at a time) then are always visible or closed.
> >
> > "Tom Ogilvy" wrote:
> >
> > > for each frm in Userforms
> > > if lcase(frm.name) = "frmabc" then
> > > ' frm is loaded
> > > if frm.visible then
> > > ' frm is visible
> > > end if
> > > end if
> > > Next
> > >
> > > Obviously if the useform isn't loaded, then it can't be visible.
> > >
> > > --
> > > Regards,
> > > Tom Ogilvy
> > >
> > >
> > > "Excel 2003 - SPB" wrote:
> > >
> > > > I am trying to find code for indentifying if a user form is open
> > > >
> > > > Thanks
> > > >
> > > > SPB

 
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
code to open blank form activates code to show record has changed Repent Microsoft Access Forms 2 20th May 2009 05:24 PM
Open Appointment form from User Form code and add the attemdee ite masani paresh Microsoft Outlook Form Programming 2 11th Feb 2009 11:59 AM
Code to Open New Form Based on Input Form Answer Alan Microsoft Access Forms 2 28th Aug 2008 03:42 PM
Code to open a Form using both idAcct and idOrder to identify the Form ?? MyEmailList@gmail.com Microsoft Access 0 26th Apr 2007 10:13 PM
how do I keep a form open but only process code after the form after a certain button on the form is clicked? Keith G Hicks Microsoft Access Form Coding 1 3rd Dec 2003 08:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:28 AM.