Is the form loaded?

  • Thread starter Thread starter DubboPete
  • Start date Start date
D

DubboPete

Hi all,

I have seen many previous posts on tis subject, but most include calling a
function to check whether a form is open - and I can't get my head around
that yet, no matter how many times I try! More on that towards the latter
end of this post.

This is the scenario. Main menu [switchboard] opens, and then I select
option one, which opens a form to select records for printing. It's as
simple as that, with a form in between to select the processing date.
When selecting option one, the first form opened is [Calendar] where the
user selects the processing date, using a Calendar Control. At this point
[switchboard] becomes 'visible = false'. Back to the [Calendar] form.
When the required date is selected, the [Calendar] form becomes 'visible =
false', and the actual processing form opens up [MyList] - that part works
fantastic. Once the required records on [MyList] are actioned, the user
has the choice to print or return to the main menu [Switchboard].

Now, my predicament. I know I haven't followed all normal conventions with
the other forms and actions that occur from the processing form. That's due
to VB ignorance/lack of knowledge on my part.

I just need to find out if a particular form is open ('IsLoaded') when I run
the next chosen event - whatever that may be, from closing forms to printing
reports; and without using the functions so popularly demonstrated on this
news group, I need to know if there is an instance of an "if..then..." I can
put in the code to move to the next line of code in either instance,
depending on the '0' or '-1' answer.

Until I work out the placement of functions within the database and get them
to work, I have to rely on "if..then..." scanarios, which have kept me out
of the doggy doo-doo so far...

I hope you have all kept up with me so far, and someone can offer some
simply obvious answer that is evading me!

Part Two - This IS OPTIONAL!
Now back to the functions.... This has been the bane of my [Access] life.
I see many references to using a function to find out if a form is open, as
in

Public Function IsLoaded(ByVal strFormName As String) As Integer

and so on

I can relate to the logic, but I don't have a clue where or how to apply it!
Do I create a new module, and then save it as a module called [IsLoaded],
or what? Or am I thinking along totally wrong lines????

Sorry for the latter question, and hope the first problem gets answered
first. If anyone has the inclination to take it to the latter question,
and help me find out more information on that, then I truly thank you for
your perseverance and patience! But, as I emphasised above, if the first
part can be easily answered, I will use that to fix my problem, and take
great heed to any answers to Part Two!

TIA

DubboPete
 
Open the Northwind sample database.
Open the module named Utility Functions.
That's exactly how you need to create the IsLoaded() function.

If you are using Access 2000 or later, you don't need the function. Just use
use:
If CurrentProject.AllForms("MyForm").IsLoaded Then
replacing MyForm with the name of your form.

You're actually from Dubbo, Pete?
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DubboPete said:
I have seen many previous posts on tis subject, but most include calling a
function to check whether a form is open - and I can't get my head around
that yet, no matter how many times I try! More on that towards the
latter end of this post.

This is the scenario. Main menu [switchboard] opens, and then I select
option one, which opens a form to select records for printing. It's as
simple as that, with a form in between to select the processing date. When
selecting option one, the first form opened is [Calendar] where the user
selects the processing date, using a Calendar Control. At this point
[switchboard] becomes 'visible = false'. Back to the [Calendar] form.
When the required date is selected, the [Calendar] form becomes 'visible =
false', and the actual processing form opens up [MyList] - that part works
fantastic. Once the required records on [MyList] are actioned, the user
has the choice to print or return to the main menu [Switchboard].

Now, my predicament. I know I haven't followed all normal conventions
with the other forms and actions that occur from the processing form.
That's due to VB ignorance/lack of knowledge on my part.

I just need to find out if a particular form is open ('IsLoaded') when I
run the next chosen event - whatever that may be, from closing forms to
printing reports; and without using the functions so popularly
demonstrated on this news group, I need to know if there is an instance of
an "if..then..." I can put in the code to move to the next line of code in
either instance, depending on the '0' or '-1' answer.

Until I work out the placement of functions within the database and get
them to work, I have to rely on "if..then..." scanarios, which have kept
me out of the doggy doo-doo so far...

I hope you have all kept up with me so far, and someone can offer some
simply obvious answer that is evading me!

Part Two - This IS OPTIONAL!
Now back to the functions.... This has been the bane of my [Access]
life. I see many references to using a function to find out if a form is
open, as in

Public Function IsLoaded(ByVal strFormName As String) As Integer

and so on

I can relate to the logic, but I don't have a clue where or how to apply
it!
Do I create a new module, and then save it as a module called [IsLoaded],
or what? Or am I thinking along totally wrong lines????

Sorry for the latter question, and hope the first problem gets answered
first. If anyone has the inclination to take it to the latter question,
and help me find out more information on that, then I truly thank you for
your perseverance and patience! But, as I emphasised above, if the first
part can be easily answered, I will use that to fix my problem, and take
great heed to any answers to Part Two!

TIA

DubboPete
 
Thanks Allen,

1. Much appreciated... and working on it (tomorrow!)

2. live in Dubbo, not born there!

cheers
DubboPete

Allen Browne said:
Open the Northwind sample database.
Open the module named Utility Functions.
That's exactly how you need to create the IsLoaded() function.

If you are using Access 2000 or later, you don't need the function. Just
use use:
If CurrentProject.AllForms("MyForm").IsLoaded Then
replacing MyForm with the name of your form.

You're actually from Dubbo, Pete?
--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

DubboPete said:
I have seen many previous posts on tis subject, but most include calling
a function to check whether a form is open - and I can't get my head
around that yet, no matter how many times I try! More on that towards
the latter end of this post.

This is the scenario. Main menu [switchboard] opens, and then I select
option one, which opens a form to select records for printing. It's as
simple as that, with a form in between to select the processing date.
When selecting option one, the first form opened is [Calendar] where the
user selects the processing date, using a Calendar Control. At this
point [switchboard] becomes 'visible = false'. Back to the [Calendar]
form. When the required date is selected, the [Calendar] form becomes
'visible = false', and the actual processing form opens up [MyList] -
that part works fantastic. Once the required records on [MyList] are
actioned, the user has the choice to print or return to the main menu
[Switchboard].

Now, my predicament. I know I haven't followed all normal conventions
with the other forms and actions that occur from the processing form.
That's due to VB ignorance/lack of knowledge on my part.

I just need to find out if a particular form is open ('IsLoaded') when I
run the next chosen event - whatever that may be, from closing forms to
printing reports; and without using the functions so popularly
demonstrated on this news group, I need to know if there is an instance
of an "if..then..." I can put in the code to move to the next line of
code in either instance, depending on the '0' or '-1' answer.

Until I work out the placement of functions within the database and get
them to work, I have to rely on "if..then..." scanarios, which have kept
me out of the doggy doo-doo so far...

I hope you have all kept up with me so far, and someone can offer some
simply obvious answer that is evading me!

Part Two - This IS OPTIONAL!
Now back to the functions.... This has been the bane of my [Access]
life. I see many references to using a function to find out if a form is
open, as in

Public Function IsLoaded(ByVal strFormName As String) As Integer

and so on

I can relate to the logic, but I don't have a clue where or how to apply
it!
Do I create a new module, and then save it as a module called
[IsLoaded], or what? Or am I thinking along totally wrong lines????

Sorry for the latter question, and hope the first problem gets answered
first. If anyone has the inclination to take it to the latter question,
and help me find out more information on that, then I truly thank you for
your perseverance and patience! But, as I emphasised above, if the
first part can be easily answered, I will use that to fix my problem, and
take great heed to any answers to Part Two!

TIA

DubboPete
 
Back
Top