Locking a button once clicked

  • Thread starter chris0309 via AccessMonster.com
  • Start date
C

chris0309 via AccessMonster.com

I have a load button on a form, once clicked I would like the button to be
locked.

Please can someone help as I have no idea how to carry this out?

Many thanks in advance.

Chris
 
D

Danny J. Lesandrini

There's a trick to this, since you can't lock a button while it has the focus.

I'm assuming you know how to get to the button's OnClick event in VBA, right?
Then add code something like this ...

Me!txtSomeTextBox.SetFocus
Me!cmdYourButton.Locked = True
 
F

fredg

I have a load button on a form, once clicked I would like the button to be
locked.

Please can someone help as I have no idea how to carry this out?

Many thanks in advance.

Chris

What is a "Load Button"?
Do you mean a command button?

Code it's click event:

' Do whatever the click event should do here, then ...
Me.AnyOtherControl.SetFocus
Me.CommandButtonName.Enabled = False
 
C

chris0309 via AccessMonster.com

The problem is all my text boxes are within a sub form and the command button
is located outside on the main form. Is there a way to link the text box
control to a sub form?

Chris
There's a trick to this, since you can't lock a button while it has the focus.

I'm assuming you know how to get to the button's OnClick event in VBA, right?
Then add code something like this ...

Me!txtSomeTextBox.SetFocus
Me!cmdYourButton.Locked = True
I have a load button on a form, once clicked I would like the button to be
locked.
[quoted text clipped - 4 lines]
 
C

chris0309 via AccessMonster.com

The problem is all my text boxes are within a sub form and the command button
is located outside on the main form. Is there a way to link the text box
control to a sub form?

Chris
There's a trick to this, since you can't lock a button while it has the focus.

I'm assuming you know how to get to the button's OnClick event in VBA, right?
Then add code something like this ...

Me!txtSomeTextBox.SetFocus
Me!cmdYourButton.Locked = True
I have a load button on a form, once clicked I would like the button to be
locked.
[quoted text clipped - 4 lines]
 
D

Danny J. Lesandrini

Ok, you have to get creative here. We can't see your form so we don't know
what to tell you as to what to set focus to. Did it ever cross your mind that you
might set focus to the subform? Yup, a subform will accept focus. Problem solved.

Alternatively, you can execute this line instead

SendKeys "{Tab}"

That will simply tab off of the command button, unless the command button is the
only control, which would be a little odd. Course, this SendKeys call might toggle
your user's CAPS LOCK on and off, but it's a small price to pay.

--
Danny J. Lesandrini
(e-mail address removed)
www.amazecreations.com


chris0309 via AccessMonster.com said:
The problem is all my text boxes are within a sub form and the command button
is located outside on the main form. Is there a way to link the text box
control to a sub form?

Chris
There's a trick to this, since you can't lock a button while it has the focus.

I'm assuming you know how to get to the button's OnClick event in VBA, right?
Then add code something like this ...

Me!txtSomeTextBox.SetFocus
Me!cmdYourButton.Locked = True
I have a load button on a form, once clicked I would like the button to be
locked.
[quoted text clipped - 4 lines]
 
C

chris0309 via AccessMonster.com

Did not know you could set the control to a form, thats worked. Thats a lot
really appreciate your time and help.
The problem is all my text boxes are within a sub form and the command button
is located outside on the main form. Is there a way to link the text box
control to a sub form?

Chris
There's a trick to this, since you can't lock a button while it has the focus.
[quoted text clipped - 9 lines]
 
L

Linq Adams via AccessMonster.com

SendKeys is always a bad idea, and should only be used when there is
absolutely no other method to get the job done.

You also need to use Fred's syntax, as a command button has no "Locked"
property.
 
L

Linq Adams via AccessMonster.com

SendKeys is always a bad idea, and should only be used when there is
absolutely no other method to get the job done.

You also need to use Fred's syntax, as a command button has no "Locked"
property.
 

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

Top