Public Variable

J

Jerry Anderson

I have a startup form ("Home") with a combo box that allows the user to
select a cost center. Once selected, I want the application to remember that
cost center, and reuse it with multiple forms. I can make it work by keeping
the form open and referring to the control from other forms, but it gets
messy to have some many forms still open.
I thought a Public variable would solve my problem, but I don't know how to
make it work, since I am but a newbie.
Can anyone help?
 
J

John W. Vinson

I have a startup form ("Home") with a combo box that allows the user to
select a cost center. Once selected, I want the application to remember that
cost center, and reuse it with multiple forms. I can make it work by keeping
the form open and referring to the control from other forms, but it gets
messy to have some many forms still open.
I thought a Public variable would solve my problem, but I don't know how to
make it work, since I am but a newbie.
Can anyone help?

Keeping your startup form open is probably the best idea. You can make it
invisible if you want it out of view. Public variables can lose their value if
the code gets interrupted (by an error say), and have other problems.

I'll usually have my switchboard form (home-grown not Microsoft's) open at all
times. It doesn't strike me as messy (there'd usually only be two forms open
at once, one hidden, so where's the mess?)
 
D

Dirk Goldgar

Jerry Anderson said:
I have a startup form ("Home") with a combo box that allows the user to
select a cost center. Once selected, I want the application to remember
that
cost center, and reuse it with multiple forms. I can make it work by
keeping
the form open and referring to the control from other forms, but it gets
messy to have some many forms still open.
I thought a Public variable would solve my problem, but I don't know how
to
make it work, since I am but a newbie.
Can anyone help?


A public variable might be a solution, but how about just hiding the startup
form? If you make it invisble, using a line of code like this:

Me.Visible = False

.... in one of its events (chosen as apropriate), it shouldn't be messy any
longer, and you can still refer to controls on it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top