Button visible IF other form is open

SteveC24

Registered User.
Local time
Today, 23:11
Joined
Feb 1, 2003
Messages
444
Hi,

I have a menu form, which has a button on it to open a "Shops" form. I want the Shops form to display a button on it, ONLY if the Menu form is open.

The button is set to be not visible normally, the code should change that.....but doesn't.

This is what I have so far:

Code:
If IsFormLoaded("frm menu") = True Then
closebutton.Visible = True
Else
Exit Sub
End If

I also have this module:

Code:
Function IsFormLoaded(strFormName As String) As Boolean
IsFormLoaded = (SysCmd(acSysCmdGetObjectState, acForm, strFormName) = acObjStateOpen)
End Function

Thanks!
 
Try this function:

Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const OBJ_STATE_CLOSED = 0
Const DESIGN_VIEW = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> OBJ_STATE_CLOSED Then
If Forms(strFormName).CurrentView <> DESIGN_VIEW Then
IsLoaded = True
End If
End If
End Function

hth,
Jack
 
Pat, I tried your suggestion, but it doesn't seem to make any difference.

Jack, I tried that, and I get this error:

Compile Error:

Expected variable or procedure, not module.


I have this as a module, called IsLoaded:

Code:
Function IsLoaded(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.

Const OBJ_STATE_CLOSED = 0
Const DESIGN_VIEW = 0

If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> OBJ_STATE_CLOSED Then
If Forms(strFormName).CurrentView <> DESIGN_VIEW Then
IsLoaded = True
End If
End If
End Function

Then, I have this in the form, in the On_load event:

Code:
If IsLoaded("frm menu") = True Then
closebutton.Visible = True
Else

Help! I have very limited knowledge of VBA BTW!!!
 
Ah right, OK, I have left the function called IsLoaded, and have called the module IsFormLoaded.

Now, I am getting the following error:

Compile Error:

Invalid Qualifier


It highlights this part of my code:

Code:
closebutton.Visible = True


Thanks,
 
Rich -

You are too fast for me Rich!

Steve -

The code does work...

Jack
 
Thanks Rich, with that little tinkering, and a little fiddling with my shoddy coding, I have got it working great!

Thanks both of you - sorry Jack, your code does work! :)

Thanks
 
I am glad you have your problem sorted and your code working!

Jack
 

Users who are viewing this thread

Back
Top Bottom