Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling a Command Button

Status
Not open for further replies.

Mike555

Technical User
Feb 21, 2003
1,200
US
Is it possible to disable a command button after it has used one time? The Access2K db I'm working on has a form in which users enter information and click a "Submit" command button to submit the data. However, I want to prevent any data from being submitted twice, so I need to have the command button disable after one use.

Any suggestions?

Thanks.
Mike Mason, MCSE
 
In the On Click event of the command button you want to disable, insert code like this at the end of the routine to set the focus to another control. (You can't disable a control while it has the focus):
Code:
Me.AnotherCommandButton.SetFocus
In the On Got Focus event of the second command button, put code like this to disable the button you want to disable:
Code:
Me.FirstCommandButton.Enabled = False
 
(You can't disable a control while it has the focus):


Ahhhh.. but you can make it transparent, which makes it rather hard to click.. [bigsmile]

....
me.cmdButton.Transparent = True
....

The only problem with this is that the button is still "there", and active - so if you click in the spot where the button is, it will run the CLICK event.

I frequently use small, transparent buttons to act as an "escape hatch" from black-box applications. Since I'm the only one who knows they're there, I don't have to worry about inadvertent clicks. And I make them REALLY REALLY small.. [smile]

J
Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Well, it would have been easier to make it invisible too, but that's not what Mike asked for.......
 
The form on which this command button appears is a continuous form. If I would apply the transparent effect, would the button then be transparent for all forms after the button is used on the first form?
 
If you mean will it be transparent on all the RECORDS of the continuous detail section, then YES, it will be. Apart from conditional formatting of values, anything you do to a row in the detail section of a continuous form will apply to the entire detail section.





Me? Ambivalent? Well, yes and no....
Another free Access forum:
More Access stuff at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top