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

Newbie problem! Cannot find advice for this anywhere.

P: 4
Hi!

I'm making a form that has checkboxes and want to handle the checked checkboxes in code. The problem is that I don't know how to do it! Here is what I've tried so far:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmd_update_Click()
  2. On Error GoTo Err_cmd_update_Click
  3.  
  4. Dim rowsToUpdate As String
  5.  
  6.     If check_a.Value Then
  7.         rowsToUpdate = rowsToUpdate & "A"
  8.     End If
  9.     If check_b.Value Then
  10.         rowsToUpdate = rowsToUpdate & "B"
  11.     End If
  12.     If check_c.Value Then
  13.         rowsToUpdate = rowsToUpdate & "C"
  14.     End If
  15.     If check_d.Value Then
  16.         rowsToUpdate = rowsToUpdate & "D"
  17.     End If
  18.     If check_e.Value Then
  19.         rowsToUpdate = rowsToUpdate & "E"
  20.     End If
  21.     If check_f.Value Then
  22.         rowsToUpdate = rowsToUpdate & "F"
  23.     End If
  24.     If check_g.Value Then
  25.         rowsToUpdate = rowsToUpdate & "G"
  26.     End If
  27.     If check_h.Value Then
  28.         rowsToUpdate = rowsToUpdate & "H"
  29.     End If
  30.     If check_i.Value Then
  31.         rowsToUpdate = rowsToUpdate & "I"
  32.     End If
  33.     If check_j.Value Then
  34.         rowsToUpdate = rowsToUpdate & "J"
  35.     End If
  36.  
  37.     FillFudes.FillFudes (rowsToUpdate)
  38.  
  39. Exit_cmd_update_Click:
  40.     Exit Sub
  41.  
  42. Err_cmd_update_Click:
  43.     MsgBox Err.Description
  44.     Resume Exit_cmd_update_Click
  45.  
  46. End Sub
  47.  
For some reason it seems that the button that should trigger this event never even gets in this code here?!
Oct 17 '06 #1
Share this Question
Share on Google+
1 Reply


MMcCarthy
Expert Mod 10K+
P: 14,534
To check if a checkbox is ticked you need to check if it is -1 or 0. Also go to the form design view and check the properties of the cmd_update button. In the events tab make sure that [Event Procedures] is in the OnClick event and in the Other tab make sure the name of the button is cmd_update.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmd_update_Click()
  3. On Error GoTo Err_cmd_update_Click
  4.  
  5. Dim rowsToUpdate As String
  6.  
  7. If check_a = -1Then
  8. rowsToUpdate = rowsToUpdate & "A"
  9. End If
  10. If check_b = -1Then
  11. rowsToUpdate = rowsToUpdate & "B"
  12. End If
  13. If check_c = -1Then
  14. rowsToUpdate = rowsToUpdate & "C"
  15. End If
  16. If check_d = -1Then
  17. rowsToUpdate = rowsToUpdate & "D"
  18. End If
  19. If check_e. = -1Then
  20. rowsToUpdate = rowsToUpdate & "E"
  21. End If
  22. If check_f = -1Then
  23. rowsToUpdate = rowsToUpdate & "F"
  24. End If
  25. If check_g = -1Then
  26. rowsToUpdate = rowsToUpdate & "G"
  27. End If
  28. If check_h = -1Then
  29. rowsToUpdate = rowsToUpdate & "H"
  30. End If
  31. If check_i = -1Then
  32. rowsToUpdate = rowsToUpdate & "I"
  33. End If
  34. If check_j = -1Then
  35. rowsToUpdate = rowsToUpdate & "J"
  36. End If
  37.  
  38. FillFudes.FillFudes (rowsToUpdate)
  39.  
  40. Exit_cmd_update_Click:
  41. Exit Sub
  42.  
  43. Err_cmd_update_Click:
  44. MsgBox Err.Description
  45. Resume Exit_cmd_update_Click
  46.  
  47. End Sub
  48.  
  49.  
For some reason it seems that the button that should trigger this event never even gets in this code here?![/quote]
Oct 17 '06 #2

Post your reply

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