Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2004
    Posts
    2

    Unanswered: Query help needed

    I have 30 check boxes (not my design) on one form and I need to know how to do a query when only one is selected or 10 is selected ...If you need more info, please reply.. Thanks so much

  2. #2
    Join Date
    Nov 2004
    Posts
    32
    Tow seperate approaches spring to mind:

    In the query a condition on the lines of:

    IIF(Forms!myForm!tick1=true,a,b)

    OR

    aet up a condition in the ontick (or onclick) event to check the value of the tick box, and then store this in a variable, reachec through set and get. Check this variable in the query...

    Sorry if that's a bit hasty, I don't have all my code with me at the moment, but either way is a bit of a pain!

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    There may (must be) be a better & neater solution, but as a quick and dirty solution
    run an initial query which derives a value frrm the checkbox columns, much as I hate to say it using the IIF construct
    eg
    select mycol1,mycol2,mycol3,iif(myCheckbox1=true,1,0) as ckb1,iif(myCheckbox2=true,1,0) as ckb2....iif(myCheckbox10==true,1,0) as ckb10
    from.........
    where.......
    order by.......

    then run another query referrring to the first one
    summing the values of ckb1..ckb10

    then a third query refering to the intermediate one above extracting if the sum is either 1 or 10

    Its nasty but it should work. I have been forced to use such a strategy before and am not proud of it.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Sorry I think I misread you intial request a second stab if you want to return a row either checkbox 1 OR checkbox 10 is true
    place the following in your where clause

    if only where term
    where myCheckbox1=true or mycheckbox10=true
    if other where temrs already exist
    and (myCheckbox1=true or mycheckbox10=true)

  5. #5
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Quote Originally Posted by mray
    I have 30 check boxes (not my design) on one form and I need to know how to do a query when only one is selected or 10 is selected ...If you need more info, please reply.. Thanks so much
    HI MRay and "Welcome to the Forum"

    Are you viewing the Results in a Report? I have such a form as well and is based on an underlying query. Thing is, whenever I populate a CheckBox, it shows in the Report automatically. The trick here is that Before that is done I have ONE CheckBox called quite simply Print. When that is checked, it opens the Report to show only those records that have the Print CheckBox selected, and all the other fields come along for the ride.....that means the other CheckBoxes and all.
    A bit more about your design or can you make a copy and Zip and Post it here to take a look at? Might be able to fix that for you.

    have a nice one,
    BUD

Posting Permissions

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