469,613 Members | 1,208 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

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 1354
vb5prgrmr
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..
  4.  


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 gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.