473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to check a form if it is opened ?

222 100+
Hello everybody


I'm using access 2003

Sometimes I use to open more than form in my project what I need is to check another form if still opened

For example I have :

form name X,Y,Z

I got the focus into X what I need to check is whether Y and Z from are opened ?
Is ther any module on VB for that ... If not any method please ....
Jun 25 '07 #1
5 6476
NeoPa
32,556 Expert Mod 16PB
You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
Jun 25 '07 #2
NeoPa
32,556 Expert Mod 16PB
Hello everybody


I'm using access 2003

Sometimes I use to open more than form in my project what I need is to check another form if still opened

For example I have :

form name X,Y,Z

I got the focus into X what I need to check is whether Y and Z from are opened ?
Is ther any module on VB for that ... If not any method please ....
The Forms collection holds all the open forms.
You can access it via a loop or via the form's name.
Let us know how you get on with this :)
Jun 25 '07 #3
wassimdaccache
222 100+
I found it..........


I declare this module
Expand|Select|Wrap|Line Numbers
  1. Public Function Isopen(fn As String) As Boolean 'returns True if form is open
  2. If SysCmd(acSysCmdGetObjectState, acForm, fn) <> 0 Then Isopen = True
  3. End Function
then I use this function

Expand|Select|Wrap|Line Numbers
  1. if ( isopen(X) ) then 
  2. msgbox "X IS OPEN " ,,vbinformation 
  3. else
  4. msgbox " not open ",,vbinformation 
  5. end if
byyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
Jun 25 '07 #4
ADezii
8,834 Expert 8TB
Hello everybody


I'm using access 2003

Sometimes I use to open more than form in my project what I need is to check another form if still opened

For example I have :

form name X,Y,Z

I got the focus into X what I need to check is whether Y and Z from are opened ?
Is ther any module on VB for that ... If not any method please ....
You didn't specify what Version of Access you are running, so I'll stay with the simplest and most basic approach, the Forms Collection.
  1. NeoPa already pointed you in the right direction in that the Forms Collection contains only the Forms that are Opened. If a Form is not contained within this Collection, it is not open.
  2. Copy and Paste this code in a Standard Code Module.
    Expand|Select|Wrap|Line Numbers
    1. Public Function fIsFormOpen(FormName As String) As Boolean
    2. Dim frm As Form
    3.  
    4. For Each frm In Forms
    5.   If frm.Name = FormName Then
    6.     fIsFormOpen = True
    7.       Exit Function
    8.   Else
    9.     fIsFormOpen = False
    10.   End If
    11. Next
    12. End Function
  3. Call the Function as indicated below.
    Expand|Select|Wrap|Line Numbers
    1. If fIsFormOpen("X") Then
    2.   Debug.Print "Form X is Open"
    3. Else
    4.   Debug.Print "Form X is NOT Open"
    5. End If
NOTE: After seeing wassimdaccache's Post, you are probably better using his approach.
Jun 25 '07 #5
NeoPa
32,556 Expert Mod 16PB
The Forms approach can be used quite simply :
Expand|Select|Wrap|Line Numbers
  1. Public Function IsFormOpen(strForm As String) As Boolean
  2.     IsFormOpen = False
  3.     'If form open, the test will always return TRUE, otherwise FALSE
  4.     On Error Resume Next
  5.     IsFormOpen = (Forms(strForm).Name = strForm)
  6. End Function
Lines 2 & 3 are essentialy unnecessary.
Jun 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Shyguy | last post by:
I have two forms that both open the same (3rd) form. The third form does the same thing, but a little differently depending on which form it is opened from. Is there a way I can check which form...
1
by: Susan Bricker | last post by:
Greetings. I am trying to position opened forms so that they are cascaded on the screen. I have discovered the movesize action (for the DoCmd) and Move property of a form (for Acc 2002/2003). ...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
30
by: S. van Beek | last post by:
Dear reader A record set can be empty because the condition in the query delivers no records. Is there a VBA code to check the status of a record set, record set empty
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
3
by: Eagle | last post by:
Hi, I've got an input form (frmInput) that can be accessed in two ways. A combobox on this form either gets filled in by a selection on an already opened form (frmBasic), or one can input a...
6
by: JayDawg | last post by:
Is there a way to tell access to open or make visible one of two other forms/subforms depending upon whether the yes no check box is true or false. I have a data entry form that collects data on...
0
by: avi1000 | last post by:
Hi I want to do something with microsoft Word spell check and I wanted to know if it's possible. I have a TextBox and I want to check the word in the textbox with the help of Word spellcheck. I...
1
by: Mohit | last post by:
Hi all, I am working on a windows based client server application with multiple forms. All forms are having custom title bars with no default bars. There is one main form. Some forms are opened up...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.