By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Command Button enters value of 1 in field

P: 2
Hi

I am creating a simple form but am new to access and I have a field that is Apple and I want a button on the form that when pressed it puts a value of 1 in the field

Is there anyway to get the button to change colour when pressed

if the button is then pressed again can it go back to the original colour and the field value goes back to zero?

Mike
Nov 29 '16 #1

✓ answered by PhilOfWalton

If the Apple control is unbound, you need to set it's Default value to 0.

Then a bit of Code:-
Expand|Select|Wrap|Line Numbers
  1. Sub MyButton_Click
  2.     If Apple = 0 then
  3.        MyButton.BackColor = VbRed
  4.        Apple = 1
  5.     Else
  6.        MyButton.BackColor = VbGreen
  7.        Apple = 0
  8.     End If
  9. End Sub
  10.  
Phil

Share this Question
Share on Google+
1 Reply


PhilOfWalton
Expert 100+
P: 1,430
If the Apple control is unbound, you need to set it's Default value to 0.

Then a bit of Code:-
Expand|Select|Wrap|Line Numbers
  1. Sub MyButton_Click
  2.     If Apple = 0 then
  3.        MyButton.BackColor = VbRed
  4.        Apple = 1
  5.     Else
  6.        MyButton.BackColor = VbGreen
  7.        Apple = 0
  8.     End If
  9. End Sub
  10.  
Phil
Nov 29 '16 #2

Post your reply

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