Label text on Form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form with 2 different command buttons of which only cmdButton1 is enabled. cmdButton2 is enabled only fter the cmdButton1 is double clicked. I have included the code for this in the event procedure for cmdbutton1. The problem is this works only if the form is open. If the cmdButton1 is doubleclicked, cmdButton2 is enabled - but If the form is closed and reopened again, cmdButton2 is disabled again. How do I store the status of cmdButton2 when the form is closed or the application is quit

Help is highly appreciated

Thanks in advanc
Priya
 
you can declare a public variable on a module.

try this:

create a module and add a boolean public:
public bolShowCommand as boolean.

now on you form set bolShowCommand to true when you click on the command
button 1. At the same time enable the cmdButton2

On Open_Form add:
me.cmdButton2.enabled = bolshowcommand

Basically, bolshowcommand is set to true the first time you click on
cmdButton1 and it mantains it's value until you close your database (or
something else changes it back to false). Then everytime you open the form
cmdButton2 gets it's enabled property set to true or false (whatever
bolshowcommand is)

Rodrigo.

Priya said:
I have a form with 2 different command buttons of which only cmdButton1 is
enabled. cmdButton2 is enabled only fter the cmdButton1 is double clicked.
I have included the code for this in the event procedure for cmdbutton1. The
problem is this works only if the form is open. If the cmdButton1 is
doubleclicked, cmdButton2 is enabled - but If the form is closed and
reopened again, cmdButton2 is disabled again. How do I store the status of
cmdButton2 when the form is closed or the application is quit.
 
This works-Thank you
But the value for the boolean variable is lost when I quit and restart Access
Is there a way to retain the value even if the application is quit

Thanks in advanc
Priy

----- Rodrigo wrote: ----

you can declare a public variable on a module

try this

create a module and add a boolean public
public bolShowCommand as boolean

now on you form set bolShowCommand to true when you click on the comman
button 1. At the same time enable the cmdButton

On Open_Form add
me.cmdButton2.enabled = bolshowcomman

Basically, bolshowcommand is set to true the first time you click o
cmdButton1 and it mantains it's value until you close your database (o
something else changes it back to false). Then everytime you open the for
cmdButton2 gets it's enabled property set to true or false (whateve
bolshowcommand is

Rodrigo

Priya said:
I have a form with 2 different command buttons of which only cmdButton1 i
enabled. cmdButton2 is enabled only fter the cmdButton1 is double clicked
I have included the code for this in the event procedure for cmdbutton1. Th
problem is this works only if the form is open. If the cmdButton1 i
doubleclicked, cmdButton2 is enabled - but If the form is closed an
reopened again, cmdButton2 is disabled again. How do I store the status o
cmdButton2 when the form is closed or the application is quit
 
Priya,

This sound to me like these two command buttons represent data of some kind,
in which case, why not store it in a table?

You could always change them from command buttons to toggle buttons
contained by an option group. That would automatically make them
Exclusively-ORed.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Priya said:
I have a form with 2 different command buttons of which only cmdButton1 is
enabled. cmdButton2 is enabled only fter the cmdButton1 is double clicked.
I have included the code for this in the event procedure for cmdbutton1. The
problem is this works only if the form is open. If the cmdButton1 is
doubleclicked, cmdButton2 is enabled - but If the form is closed and
reopened again, cmdButton2 is disabled again. How do I store the status of
cmdButton2 when the form is closed or the application is quit.
 
Like Graham said. If you want to keep this value after you quit and this
value represents data of some kind then you might want to put in on a table.
Then just check for the value every time you open your database (you can
store this value on the same variable).

Rodrigo.
 
Back
Top