Disabling a Button

rmartinez

New member
Local time
Today, 17:08
Joined
Jun 19, 2007
Messages
8
Can someone please help me,

I'm trying to create a database and create a form to make it user - friendly. My problem is I don't know how to disable buttons. An example of what I mean is as follows:

I have on a form two buttons:
Command1
Command2

Command1 is set to run a macro titled Test. What this query does is open up a table that can be edited.

Now when a person clicks on the button titled Command1, I don't want them to be able to click on Command2 which executes another macro. The only way that I want them to be able to run Command2 is after they have exited from the table opened with Command1.

Can anyone provide me with the code that will make what I want happen? I would really appreciate anyone's help.

Thanks,
Rmartinez
 
Command1 is set to run a macro titled Test. What this query does is open up a table that can be edited.
Not a good idea. Create a FORM that allows you to edit data in the table. If you open the table directly you lose control. If you have a form (and you can set it to "datasheet" view to look like a table so the user will probably not even know they aren't looking at the table, you can use events to force things to happen that you can't otherwise.
Now when a person clicks on the button titled Command1, I don't want them to be able to click on Command2 which executes another macro.
In the click event of Command1 (I would also rename your controls to meaningful names like cmdRunMacro so you know by looking what it does. That will save you, and anyone who follows after you, a lot of pain when trying to figure out what does what.) put this code:
Code:
Me.Command2.Enabled=False

The only way that I want them to be able to run Command2 is after they have exited from the table opened with Command1.
this is where having it opened as a form and not a table helps you. In the form's close event you can use Me.Command2.Enabled = True.
Can anyone provide me with the code that will make what I want happen? I would really appreciate anyone's help.
 
Thank you

Thanks, I will try it to see how it works.
 

Users who are viewing this thread

Back
Top Bottom