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

How do I populate a field with a value using a CheckBox

P: 24
What I am trying to do should be fairly simple. I have a form with an unbound CheckBox (named F1CB)and a field in record 1 of my table (named F_1). What I want to happen is if the Check Box = T Then put the value of 1 in Field F_1. If the Check Box =F Then put the value 0. If I check or uncheck the box I also want to change the value in F_1 to the appropriate 1 or 0. All that happens currently is if I check the box, F_1 = 1 and it doesn't change. Any suggestions are appreciated.

I created this code in the Checkbox properties.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Feature_1_Click()
  2. If IsNull(F1CB) Then
  3.     Me.F_1 = 0
  4. Else
  5.     Me.F_1 = 1
  6. End If
  7. End Sub
Dec 2 '11 #1

✓ answered by dsatino

Well, I now can't fathom what the check box is for. If your F_1 is a numeric field then just bind a textbox to it and type in what you want. If it's empty, you know it's null.

Share this Question
Share on Google+
5 Replies


dsatino
100+
P: 393
Why not just bind the check box to the field? That way you don't need any code. If your DB is in Access, the value would be 0 for false and -1 for true, but since it's T/F who cares.
Dec 2 '11 #2

P: 24
Ultimately the value in the F_1 field will either be Null of F1CB is unchecked, or if the Check Box = True the value will come from a separate data table. Before I can figure that part out, I just want to figure out how to basically toggle a value in the F_1 field. Instead of -1 for True, it might be $1200 or $99 or some number. What I noticed was that if I open the form and go back to the record and uncheck the box the value didn't change. I'm not sure how to fix that.
Dec 2 '11 #3

dsatino
100+
P: 393
Well, I now can't fathom what the check box is for. If your F_1 is a numeric field then just bind a textbox to it and type in what you want. If it's empty, you know it's null.
Dec 2 '11 #4

P: 24
Thanks. I think I've been over thinking the solution. I'll try binding the checkbox.
Dec 2 '11 #5

NeoPa
Expert Mod 15k+
P: 31,709
Daryl:
I'll try binding the checkbox.
Would that not suggest that you need to select post #2 as Best Answer instead of post #4?
Dec 2 '11 #6

Post your reply

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