Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Box coding problem

Status
Not open for further replies.

miaka13

Technical User
Jul 31, 2003
30
0
0
US
Hi:) I'm pretty new at coding in Access. I have a form that has several check boxes. Next to these check boxes is a word. The problem that I am having is when the box is checked, how do I get the word to move to my table. I know that multi-select box or combo box is much easier, but I can't use these in my form. The reason is that for each box that is checked, not only does the information get written to a table it is also opening up a new form that is requesting more in depth information. For example, there are three check boxes (dog, cat, bird) when the check box is checked for dog, it writes to the table that the dog was selected and then it also opens up another form called food. Here the user selects the type of food for the dog and then clicks a back button that takes them back to the orginal form where they can go and select another animal. Can someone please help me with the check box coding or give me a better idea on how to get this form to work. Thanks in advance!!
 
The checkbox has property events as do most of the other controls. Look at them and then put the code in what ever you wish.

private sub checko_click()

me.text0 = "HI KIDDO!"

exit sub

If you put this in the checkbox on_click event, it would put "HI KIDDO" in me.text0


textbox.

Rollie E
 
Rollie,
I'm a little confused. This code will not write to the table, will it? I am not sure how to tell the check box that if it is checked for it to pull the text next to it and place it in the table. For example, if the box is "dog" box is checked then the table should read: Dog yes.

 
I was just showing you how to catch it. If you want info oon how to get it to the table you have to give us more info. Is your table bound to the same form? Is the checkbox on that form? When do you want it written to the field?


Rollie E
 
OK. I figured out the check box problem, but now I've run into another problem. What I did was make 4 columns in my table with the headings being the same name as my check boxes. I then put yes/no statements for each column. The problem I am having now is that now I have a bunch of check boxes, but when I query them, all I get is a yes/no answer. How to I make a query that will count how many times an item is checked in the table?
 
Just loop thru them in code and add them.

Rollie E
 
I hate to sound really stupid, but how do I loop and add them. I'm still pretty new at this vba coding stuff. Thanks in advance. :)
 
If you are in a form, place a command button with a click event and some code. Make a textbox named txtTotal.


private sub command0_click()

me.txtTotal = 0
if chk1 then me.total = me.total + val(value1)
if chk2 then me.total = me.total + val(value2)
if chk3 then me.total = me.total + val(value3)
if chk4 then me.total = me.total + val(value4)
if chk5 then me.total = me.total + val(value5)

exit sub

Rollie E
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top