Determining if a Form is Open

  • Thread starter Thread starter George
  • Start date Start date
G

George

I would like to programmatically determine if a certain
form is open at a point in processing. It may or may not
be, depending on how the user got to where s/he is.

When I close a form, call it FormA, I want it to either
activate FormB (if it's open), or open FormC. The stuff
on FormB is applicable in one circumstance; otherwise,
it's FormC the user needs.

Thanks for your help!

George
 
Hello George

I was given this code for use in my Access 97 database and it works well for
me

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function

then you just test for your formB if formB is open then activate it and
close formA otherwise open formC and then close formA.

Hope This Helps

Randy
 
Hi George

For Access 2000+, you can use:

If CurrentProject.AllForms("FormB").IsLoaded Then

otherwise

If SysCmd(acSysCmdGetObjectState,acForm,"FormB") <> 0 Then

You can put this in a wrapper function if you like, to make it easier for
frequent use:

If FormIsOpen("FormB") Then
 
Hi Graham
I note you are based in Auckland
I am v seriously considering emigrating from UK, is there
much work?
jeff
-----Original Message-----
Hi George

For Access 2000+, you can use:

If CurrentProject.AllForms("FormB").IsLoaded Then

otherwise

If SysCmd(acSysCmdGetObjectState,acForm,"FormB") <> 0 Then

You can put this in a wrapper function if you like, to make it easier for
frequent use:

If FormIsOpen("FormB") Then

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


I would like to programmatically determine if a certain
form is open at a point in processing. It may or may not
be, depending on how the user got to where s/he is.

When I close a form, call it FormA, I want it to either
activate FormB (if it's open), or open FormC. The stuff
on FormB is applicable in one circumstance; otherwise,
it's FormC the user needs.

Thanks for your help!

George


.
 
Thanks, Graham.

I'll use your suggestions.

George

-----Original Message-----
Hi George

For Access 2000+, you can use:

If CurrentProject.AllForms("FormB").IsLoaded Then

otherwise

If SysCmd(acSysCmdGetObjectState,acForm,"FormB") <> 0 Then

You can put this in a wrapper function if you like, to make it easier for
frequent use:

If FormIsOpen("FormB") Then

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


I would like to programmatically determine if a certain
form is open at a point in processing. It may or may not
be, depending on how the user got to where s/he is.

When I close a form, call it FormA, I want it to either
activate FormB (if it's open), or open FormC. The stuff
on FormB is applicable in one circumstance; otherwise,
it's FormC the user needs.

Thanks for your help!

George


.
 
Thanks!

-----Original Message-----
Hello George

I was given this code for use in my Access 97 database and it works well for
me

Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm,
 
This is very off-topic, but I can tell you that unemployment is low and
there seems to be plenty of work around.

You might want to check the employment section of the New Zealand Herald,
which is the main Auckland-based newspaper:
http://www.nzherald.co.nz/employment/
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

madhouse said:
Hi Graham
I note you are based in Auckland
I am v seriously considering emigrating from UK, is there
much work?
jeff
-----Original Message-----
Hi George

For Access 2000+, you can use:

If CurrentProject.AllForms("FormB").IsLoaded Then

otherwise

If SysCmd(acSysCmdGetObjectState,acForm,"FormB") <> 0 Then

You can put this in a wrapper function if you like, to make it easier for
frequent use:

If FormIsOpen("FormB") Then

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


I would like to programmatically determine if a certain
form is open at a point in processing. It may or may not
be, depending on how the user got to where s/he is.

When I close a form, call it FormA, I want it to either
activate FormB (if it's open), or open FormC. The stuff
on FormB is applicable in one circumstance; otherwise,
it's FormC the user needs.

Thanks for your help!

George


.
 
Back
Top