Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2004
    Posts
    44

    Unanswered: Option Button value to a yes/no Field

    Ok, I have a ridiculously easy question, but one that I can not seem to find an answer for yet. I created a form (access' built in forms, NOT a web form), and on it, I want to put two option (radio) buttons that have a value yes, or a value no.
    I also have a field in a table, with data type "yes/no", that I want the results of the radio buttons to go to.
    For instance, I want to know if there was a violation for an event, and want the form user to answer yes, or no. When they close out the form, I want it to save either a value of yes, or value of no to the violation field that I have already set up in a table.
    I have tried using option groups and everything else I could think of. Any advice would be appreciated. Thank you.

  2. #2
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250
    A Y/N field is boolean-- a one or zero fills it, 1 for Yes an 0 for no. A radio button holds a value 1 to n, where n are the number of choices. So, for a two option radio button the values are 1 and 2. Try subtracting one when filling in your Y/N field.

  3. #3
    Join Date
    Aug 2004
    Posts
    44
    Ohhhh, that would explain a lot of my frustrations. Thanks for the explanation on that. I was wondering how to subrtact 1 from the value in order to store it to the yes/no field. In other words, what code and where would I put it on the form, to do that operation? Any hints? Thanks a lot.

  4. #4
    Join Date
    Aug 2004
    Posts
    44
    bump. Any ideas?

  5. #5
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    Subtracting one from the Option value is not logical. If you have two radio buttons, that are to correspond to Yes / No, as opposed to a checkbox, then set the Option values to 0 and 1. If you have more than 2 Options in a single Radio Button Group, then the additional options will not correspond to Yes / No, and therefore there is no reason to subtract one.

    To subtract one from the value of an Option selected in an OptionGroup, subtract one from the value assigned to the OptionGroup in the AfterUpdate event.
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

  6. #6
    Join Date
    Aug 2004
    Posts
    44
    Thanks Robert.

    I figured it out, and I didn't have to subtract anything

    Basically, if you have a field that is of yes/no type, and you want to use access forms to modify that field with two option buttons, you insert an option button group, and set the default value to 0. Then, insert your two option buttons and label them as yes and no. For the yes option button, make its value -1, and for the no option button, make its value 0. This worked fine for me, and hopefully someone can use this info in the future. Thanks for the help guys.

Posting Permissions

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