Results 1 to 9 of 9
  1. #1
    Join Date
    May 2004
    Posts
    3

    Question Unanswered: How to determine *any* control on form has been clicked?

    Hi -

    I have a form with 52 check boxes (one per US state) and would prefer a generic way to determine whether a checkbox has been clicked, then take the appropriate action.

    I already have code supporting each checkbox's click event, but would rather have a generic procedure which runs when ANY checkbox is clicked and then cycle numerically by form field through the collection of checkboxes and act appropriately. It would certainly reduce code bloat, and the time necessary for code revisions.

    I've tested every form event I've never used, but no success.

    Suggestions .....?

    Thanks -

  2. #2
    Join Date
    Sep 2003
    Posts
    228
    Are these checkboxes in an "option group"? If not they should be...
    Then you have an event to trap every time a new checkbox is selected.

    Or are they allowed to choose multiple? If that's the case, I think you should use a list box and allow multiple selection.

  3. #3
    Join Date
    May 2004
    Posts
    3
    Thanks for the reply.

    Sorry - I meant to include a reference to an option group in the original post.

    An option group won't work. These checkboxes are not mutually exclusive. Any combination of 0-52 boxes can be selected.

    A listbox would certainly work, but would be too cumbersome on the user and not allow immediate visual reference as to which states are selected.
    Last edited by VBVBVB; 10-28-04 at 17:38.

  4. #4
    Join Date
    Sep 2003
    Posts
    228
    You could create a function similar to the one below to cycle through each control on a form. You could do some checking on the name of the control and do what ever you need to do.

    Private Sub Checkbox_Click()
    Dim ctl As Control
    For Each ctl In Me.Controls
    ctl.Enabled = False
    Next
    End Sub

    Just another note on your choice of control. When filling out forms on the internet for addresses, when was the last time you saw 52 checkboxes to select the state you live in?

  5. #5
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    did you look at _Dirty() ??

    izy
    currently using SS 2008R2

  6. #6
    Join Date
    May 2004
    Posts
    3
    izyrider:

    Thanks for the suggestion. I tried that too, no results. Unless I'm using the event incorrectly. I thought for sure there would be a way with parent or collection, since the checkbox controls communicate to their parent. I'm just not sure how to "listen" for the communication, make sense?
    --------------------------------------------------------------------------
    ottomatic:

    I don't recall writing that I was developing anything for the internet, or collecting where someone lives. I do recall thanking you for your input, but indicating why such a control would not serve my purposes.

    But to clarify why a list box would be tedious: the user will be making 50-100 entries, each of which will require applicability of any or all states indicated. Expecting someone to repeatedly make multiple selections from a list box rather than provide the ease of check boxes is shortsighted and poor implementation. It may not look "cool", but that's not the point.

    No response is better than a response with snide commentary. Thank you.

  7. #7
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004

    Unhappy

    Hi VBVBVB and "Welcome to the Forum"

    Not an Access guru but wanted to see if you know about creating Functions? I may be wrong but I think that might kinda get you what you want and then call that fucntion into each check box event? Not sure I'm in the right direction, but I kinda remember something like that in the past. Just trying to help.

    have a nice one,
    Bud

  8. #8
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    OH, forgot to ask. When they click on the check boxes what are you going to have happen when they do? Display a message or process something?

    Bud

  9. #9
    Join Date
    Sep 2003
    Posts
    228
    Your problem requires you to write a function to cycle through each checkbox checking its value. Or switching to a listbox which holds the selected items in an array.

    I didn't care for your tone in your last post to me. I was just trying to offer other solutions for your problem. My remarks were not snide and I did not know your reasons for using checkboxes... If you don't like suggestions then you are on the wrong board buddy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •