hi, anyone knows how to count the numbers of tick i've clicked on a check box and display it on a text box? when i clicked on the check box my text box appears -1. do i need to create a query? pls help me on this
What are you actually trying to count? The number of times a user has clicked on a checkbox? The number of checkboxes that are True/False? More help please
If you are simply trying to count the times a single check box is clicked you will need add some additional code to the OnClick event of the check box;
Code:
Me.TextBoxName = Me.TextBoxName + 1
If you want to see if a check box has been checked or not you can use the code I gave previously as the ControlSource for your text box, then if the check box is check the text box will have a value of one, or zero if it is unchecked.
Again, if I have a control on a form that is a tick box every time I click it it changes from True to False, back to True, etc. What is prompting the user to tick the box? and what is the purpose? a copy of the form might clear things up.
ok i'll give an eg here... the check box i use to count how many game console has sold with controller? or without controller, for that 1st person. so in the form i'll have a text box like this "total number sold with cotroller" and "total number sold without controller" so my puspose for the check box is to count how many console did the 1st sales person have sold the console with and without controllers.... hmm can u guys understand what i'm trying to do? lol
Without knowing the structure of the form and its recordSet it is a little difficult to say much.
I presume you have the With Controller and Without Controller as an Option Group so you can't select both.
In any case recording both would be redundant since there are only two options.
If you place your count text boxes in the footer of the form the code I posted will work.
However if you want to use this technique on a per employee basis you would have to use a subform.
Otherwise use a DSum expression with a condition that the employeeID equalled the EmployeeID in the current record.
the sales details is a sub form of the employee form. i've tried the code u posted... the control source i typed ABS(sum(checkbox)) but it wont work...
Note that the Sum function acts on the RecordSet not the form's controls so the argument must be the name of the field in the Record Source query or table.
Use the name of the field bound to the With Controller checkbox.
The totals controls must be in the footer of the subform.
If this was excel I'd suggest a spinner control would be the way to go, so as it's not have a look at the attached DB. The form and control are unbound simply for speed of construction. You could bind the counter field to a field in your table.
sigh i dun understand the things u guys said... hmm now i found another problem i didnt group the both checkbox together so the user can actually tick both of it.. and if i change it to the option group and i'm having two label names 1 is Yes and the other is No, do i still able to count the numbers of Yes? or No?