472,143 Members | 1,154 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Use a button only once and reset it.

OK i have a Microsoft access 2007 and i go VBA through it. What i need is, when I press a button, it should do some calculations and then disable the button. Its like when you click it, you can click the button only once and if you click one more time the data calculated would be wrong. I tried the following code first. Itm_balance and Squantity are field names.

Private Sub Command18_Click()
MsgBox "Do not click this button anymore!"
Itm_balance = Itm_balance - SQuantity
Command18.Enabled = False
End Sub

When i tried it, it gave an error message saying "Run-time error 2164, You can't disable a control while it has focus"
Can you help me to resolve this error?? You can ask more about my database also if you want. :D
May 30 '10 #1
1 1399
305 Expert 100+
Do you have another control you can set the focus to? Like a textbox?
Expand|Select|Wrap|Line Numbers
  1. Text1.SetFocus
  2. Command1.Enabled = False
  3. 'do calc..

Good Luck
May 30 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

9 posts views Thread by Ken | last post: by
7 posts views Thread by Howard Jess | last post: by
3 posts views Thread by Chris L | last post: by
2 posts views Thread by Roger Withnell | last post: by
4 posts views Thread by Ian Davies | last post: by
5 posts views Thread by zlf | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.