Go Back   Access World Forums > Microsoft Access Reference > Access FAQs

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
Old 09-13-2009, 07:00 PM   #1
ajetrumpet
Banned
 
Join Date: Jun 2007
Location: Universe - Local Group - Milky Way Galaxy - Orion Arm
Posts: 5,640
Thanks: 0
Thanked 100 Times in 47 Posts
ajetrumpet has a spectacular aura about ajetrumpet has a spectacular aura about
Send a message via MSN to ajetrumpet Send a message via Yahoo to ajetrumpet
Is my form loaded/open? (VBA check)

This works on any type of object in the database:

The system command built-in function from MS works wonders. here it is:
PHP Code:
Function GetObjState(strName StringstrType As Long) As String

dim ObjState 
as long

ObjState 
SysCmd(acSysCmdGetObjectStatestrTypestrName)

    if 
ObjState 0 then 
       
' The object is closed.
        GetObjState = "Closed"
    
elseif ObjState = 1 then 
       ' 
The object is open.
        
GetObjState "Open"

elseif ObjState 2 then 
       
' The object has been modified
        GetObjState = "Modified and UnSaved"

    end if

msgbox GetObjState

end function 
Here are the object types for the second argument:
PHP Code:
form 2
function = 10
macro 
4
module 
5
query 
1
report 
3
table 



Last edited by ajetrumpet; 09-14-2009 at 11:40 PM.
ajetrumpet is offline  
The Following User Says Thank You to ajetrumpet For This Useful Post:
hassanogaibi (06-28-2016)
Old 09-16-2009, 12:19 AM   #2
gemma-the-husky
Super Moderator
 
gemma-the-husky's Avatar
 
Join Date: Sep 2006
Location: UK
Posts: 13,769
Thanks: 55
Thanked 1,022 Times in 988 Posts
gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all gemma-the-husky is a name known to all
Re: Is my form loaded/open?

note that vba has constants for the second parameter


so

getobjstate("myform", acform)
getobjstate("myquery", acquery)

etc etc
__________________
Dave (Male!)
Gemma was my dog

if a poster helps you, please click the scales at the bottom left of this posting, or use the thanks button alongside.
gemma-the-husky is offline  
The Following User Says Thank You to gemma-the-husky For This Useful Post:
hassanogaibi (06-28-2016)
Old 09-16-2009, 08:27 AM   #3
boblarson
Smeghead
 
boblarson's Avatar
 
Join Date: Jan 2001
Location: Oregon, USA
Posts: 32,068
Thanks: 97
Thanked 1,827 Times in 1,578 Posts
boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold boblarson is a splendid one to behold
Re: Is my form loaded/open?

For most situations you don't need this code. If a form is Loaded (in Access) it is open. And therefore you can use the

CurrentProject.AllForms.IsLoaded("formNameHere")

to get the true or false as to whether it is loaded. Most of the time you do not need to know if a form/report is modifed/unsaved as we don't normally do runtime changes to design (especially with an MDE/ACCDE as you can't).

So, while this code may work, it is certainly overkill in most circumstances.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
boblarson is offline  
The Following User Says Thank You to boblarson For This Useful Post:
hassanogaibi (06-28-2016)
Old 11-17-2009, 01:17 PM   #4
liannagreyson
Registered User
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
liannagreyson is on a distinguished road
Re: Is my form loaded/open?

Very nice post with a ton of informative information. I really appreciate the fact that you approach these topics from a stand point of knowledge and information
instead of the typical “I think” mentality that you see so much on the internet these days.


Last edited by liannagreyson; 11-22-2009 at 08:41 AM.
liannagreyson is offline  
The Following User Says Thank You to liannagreyson For This Useful Post:
hassanogaibi (06-28-2016)
Closed Thread

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOw to open a POP UP form to a specified size darbid Modules & VBA 8 11-05-2012 09:41 AM
Open a form in a specific record but in different state aian Forms 19 04-08-2009 09:47 PM
Button on form to open another form Mike Hughes Forms 2 02-04-2009 03:59 AM
Open Form for filtered list of records... PhilJ Forms 3 09-07-2008 03:33 AM




All times are GMT -8. The time now is 06:39 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World