Check to ensure form is open before proceeding

BonnieG

Registered User.
Local time
Today, 14:28
Joined
Jun 13, 2012
Messages
79
I'm struggling with a bit of code and can't seem to get the syntax right.

I have an On Click procedure for one of my buttons but I don't want to allow it to run unless another form is currently open.

My other form is frm_go_live and it contains some variables relating to a project launch. I need that form to be open before my On Click procedure will work.

Something along these lines...

Code:
If (Forms!frm_go_live) [B]SOMETHING[/B] Then
    
    MsgBox "Please ensure the go live form is open before attempting to run this script."

Else
 
Define a function is loaded like:

Code:
Function IsLoaded(MyFormName As String) As Boolean
    IsLoaded = SysCmd(acSysCmdGetObjectState, acForm, MyFormName)
End Function

And test like:
Code:
If not(isloaded("frm_go_live") Then
    MsgBox "Please ensure the go live form is open before attempting to run this script."
Else

Or skip the function and use the acSysCmdGetObjectState direct like:


Code:
If SysCmd(acSysCmdGetObjectState, acForm, "frm_go_live") = 0  Then
    MsgBox "Please ensure the go live form is open before attempting to run this script."
Else
 
Thank you, that's brilliant! :) I used the second example and it works perfectly. Really appreciate it. :D
 

Users who are viewing this thread

Back
Top Bottom