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!

Using 'Tickboxes' to count 1

Status
Not open for further replies.

lamaar

Technical User
Jun 29, 2000
392
0
0
GB
I have 5 fields which are labelled at 'tickboxes'.&nbsp;&nbsp;When the boxes are ticked, I want a value (20) to be given to&nbsp;&nbsp;number field (total).&nbsp;&nbsp;When unticked, the value must fall by 20.&nbsp;&nbsp;I have tried to use an Even Procedure on the 'On Click' option within Properties but I still cannot get it to work, any ideas?<br><br>Thanks
 
I think you should use the After_Update Event and write something similar to this:<br><br>If me!TickBoxName.Value = True then<br>&nbsp;&nbsp;&nbsp;&nbsp;me!FieldName.Value = me!FieldName.Value * 1.2<br>else<br>&nbsp;&nbsp;&nbsp;&nbsp;me!FieldName.Value = me!FieldName.Value / 1.2<br>end if<br><br>HTH<br><br>Julio
 
Julio's will work if you are adding or subtracting <b>20%</b>, but if you are adding or subtracting a <b>VALUE</b> of 20, then use the following:<br><br><br>Add this sub to the code on your form, changing the bolded areas to match your field:<br><br>=====<br><br>Private Sub AdjustNumber(checked As Boolean)<br>&nbsp;&nbsp;&nbsp;&nbsp;If IsNull(Me.<b>txtTotal</b>) Then Me.<b>txtTotal</b> = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;If checked Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.<b>txtTotal</b> = Me.<b>txtTotal</b> + 20<br>&nbsp;&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Me.<b>txtTotal</b> = Me.<b>txtTotal</b> - 20<br>&nbsp;&nbsp;&nbsp;&nbsp;End If<br>End Sub<br><br>=====<br><br>Then put this this line on the Click Event of each check box, changing the &quot;chk1&quot; to the name of each check box.<br><br>Call AdjustNumber(Me.<b>chk1</b>) <br><br><br>This will work, already tried it. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top