Results 1 to 5 of 5

Thread: Multiple Checkboxes, Same Name, One Recordset

  1. #1
    Join Date
    Feb 2006
    Posts
    5

    Multiple Checkboxes, Same Name, One Recordset

    This is driving me crazy!

    I have checkboxes for days of the week, all named "AvailableDays". I want to be able to select multiple days, and write their values to one recordset in Access.

    All I get is the name of whatever was the first checkbox selected (i.e. if I select "Tuesday, Wednesday and Thursday" only Tuesday gets stored in the database).

    Here is the form code:

    Code:
     <input type="checkbox" name="AvailableDays" value="Sunday">
                  Sunday <br>
    <input type="checkbox" name="AvailableDays" value=" Monday">
                  Monday <br>
    <input type="checkbox" name="AvailableDays" value=" Tuesday">
                  Tuesday<br>
    <input type="checkbox" name="AvailableDays" value=" Wednesday">
                  Wednesday<br>
    <input type="checkbox" name="AvailableDays" value=" Thursday">
                  Thursday <br>
    <input type="checkbox" name="AvailableDays" value=" Friday">
                  Friday<br>
    <input type="checkbox" name="AvailableDays" value=" Saturday">
                  Saturday
    ...and here is my asp code:
    Code:
    RecordsetRS("AvailableDays") = Upload.Form("AvailableDays")
    I know it's something simple, but I've been looking at this all day and my eyes are getting blurry!!!

  2. #2
    Join Date
    Feb 2006
    Posts
    4
    some data is missing: how do you store the days? is it one record/field or do you want them as individual records? also why are all checkboxes named the same?

  3. #3
    Join Date
    Feb 2006
    Posts
    5
    I'm trying to keep my database as efficient as possible, so I want to store them under one record labeled 'availableDays' instead of seven different records labled with the days of the week.

    Each checkbox is labeled as 'AvailableDays' because that is how I understand checkboxes write to a record. The value of each box checked is written to a record as a string. i.e. if someone checked the boxes Monday through Wednesday the recordset for 'availableDays' would return "Monday, Tuesday, Wednesday".

    However, the way my database is working the above example just records "Monday", so either my coding is wrong or my understanding of how checkboxes get stored in a single record is incorrect.

    Hope that clears it up a little. Thanks.

  4. #4
    Join Date
    Feb 2006
    Posts
    5
    Create a new unbound control on the form. When the user clicks any of the 7 checkboxes, add the value of all the checkboxes (or only the checked boxes) to the control. Then upload the control to the record instead of uploading all 7 checkboxes.

    In the afterUpdate event of all 7 checkboxes, set the value of the control = me.checkbox1 & ";" & me.checkbox2 & ";" me.checkbox3 & ... etc. Or you could do 7 IF statements to assign the value only if checked, etc. if adding empty strings causes problems.

    By adding all 7 to the control *each time* any of the 7 are updated, the user is allowed to de-select a day since the control is recalibrated after any check or uncheck of any of the 7.

    Oh, one more thing. Each time you give different controls the same name, God kills a kitten. :-)

  5. #5
    Join Date
    Feb 2006
    Posts
    5
    Excellent solution. Thanks Beestie.

Posting Permissions

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