473,406 Members | 2,371 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,406 software developers and data experts.

Check if a form is open and if it is close it?

Hi, I am trying to check if a certain form is open and then if it is close
it. I have searched but can't find an answer. Any suggestions?

Thanks

Will
Nov 13 '05 #1
3 32695
> Hi, I am trying to check if a certain form is open and then if it is close
it. I have searched but can't find an answer. Any suggestions?


I use this:

If IsOpen("FormName") Then DoCmd.Close acForm, "FormName"

[put this function in a separate module]
Public Function IsOpen(fn As String) As Boolean 'returns True if form is
open
If SysCmd(acSysCmdGetObjectState, acForm, fn) <> 0 Then IsOpen = True
End Function
Nov 13 '05 #2
Rog
DoCmd.Close acForm, "FormName"
Access doesn't give an error if the form is not open.

Nov 13 '05 #3
deko wrote:
Hi, I am trying to check if a certain form is open and then if it is close
it. I have searched but can't find an answer. Any suggestions?

I use this:

If IsOpen("FormName") Then DoCmd.Close acForm, "FormName"

[put this function in a separate module]
Public Function IsOpen(fn As String) As Boolean 'returns True if form is
open
If SysCmd(acSysCmdGetObjectState, acForm, fn) <> 0 Then IsOpen = True
End Function


IsOpen = SysCmd(acSysCmdGetObjectState, acForm, fn)

Would return the same with less code :-)

--
This sig left intentionally blank
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MrNobody | last post by:
I'm pretty tired from working all day on this program and this one simple task of showing a certain form when the app initializes is driving me nuts... It opens very briefly then quickly...
10
by: Alex | last post by:
For example, I create Login form first. When user login, it open the main form and close the login form itself.
10
by: Saber | last post by:
I did a web search and found someone is looking for what I'm looking for: There are 2 forms...named => formA and formB and each of them have their own button named => btnA and ...
4
by: ghadley_00 | last post by:
Hi, Can anyone recommend a piece of VBA code I could attach to a button in a MS Form form that will close the current form and bring the switchboard to foreground. I'm trying to integrate a form...
1
by: stevencarroll19 | last post by:
What i wnat to do is check to see if a form is open before a new record can be entered. If any of the forms are open ( Question3 Reason, Question 4 Reason and Question 9 Comments) I want an error...
4
by: PW | last post by:
Hi, I want to add code to check if the user wants to save the record (fields are unbound) when they press the form's close (X) button. Is it possible to return the user to the form if there...
5
by: dkozel | last post by:
Hello, I am having a problem with an application, where I feel the answer should be easy; however, what seems easy sometimes is not so. I have two forms, we will call form1 and form2. Inside...
4
by: sajit | last post by:
hi folks, I am curently working in vb.net 2005. I am stuck at one technical glitch. How to open another form and close the parent foem in vb.net. I have tried every thing like me.close as well...
3
by: godhulirbalaka | last post by:
Dear Sir/Madam, I am new vb 6.0 user. I am developing Shop Management Program. I have a main form with buttons and menus. when i click any button then respective form is open. I want to set a...
3
by: rajashekar4dotnet | last post by:
how to open one form from the other form and close the first form if there are only two forms in windows application(VB.net) i had tried this method dim f as new form2 form2.show( )...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.