473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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

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.

5 2642
dsatino
393 256MB
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
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
393 256MB
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
Thanks. I think I've been over thinking the solution. I'll try binding the checkbox.
Dec 2 '11 #5
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

2
by: Patrick | last post by:
I currently us JavaScript to populate a hidden field with my scroll location in order to retain the page location when I post the page back to itself. However, I don't know how to pass that hidden...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
3
by: tony lock | last post by:
I am writing a simulation program, the main classes inherit from a base class which itself inherits from Control. I am using reflection to serialize these objects including the fields from control....
2
by: xenophon | last post by:
I added a Hidden Form Field to a form in the code behind. The value is being set in JavaScript client-side, but it is not persisting to the server in the PostBack. I know the value is being set...
5
by: eihabisaac | last post by:
hi i have a field in my database (status) which have the value 0 or 1 how can i update these value using check box if checked then 1 if not checked then 0 and also how to insert values...
1
by: aboon | last post by:
Hi I need help with showing field when checkbox checked and hiding field when the checkbox is unchecked. I was able to do it using dropdownlist but I'm not able to do it with checkboxlist at all....
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
1
by: ramel | last post by:
Hi all, I have a problem related to javascript , ajax and jsp. Please see this url http://xil.co.in/print_screen_2.JPG. I am working on this form. There are some buttons (like submit ,...
1
by: puneetmca | last post by:
hi...this code of deleting a record from database using checkbox is not working...echo "<td>$row</td>; echo "<td>$row</td>"; echo "<td>$row....these lines print as it is...rather then...
1
by: azie | last post by:
hi.. Can someone help me, how to populate textbox value from popup window into gridview at parent page. I use modal popup window (window.showModalDialog). At parent page have button add where will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.