Results 1 to 7 of 7
  1. #1
    zero3ree is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2010
    Posts
    39

    Adding values to checkboxes

    Hello,

    I am trying to set up a estimation form. What I want to accomplish is to have multiple checkboxes that a user would select the boxes relevant to his project. From these selections there would be a sum created. Each box could have different values. I tried using the default value but when I unchecked and rechecked it went back to using -1.

    I am thinking I will need to assign values through a query but I want to show the sum on my form.



    Any help would be appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    check boxes are only ON or OFF. they dont have anything else.
    now, OPTION buttons can have different values.
    put them into a frame
    ex: the frame fraPARTY
    would have options buttons inside the frame
    REPUBLICAN
    DEMOCRATE
    INDEPENDENT
    OTHER

    set the repub opt value = 1
    demo = 2
    etc
    THEN whatever gets picked the value is passed to fraPARTY.value. THIS is what is stored in the table.

  3. #3
    zero3ree is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2010
    Posts
    39
    Thank you. I will try that out.

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You have said HOW you are doing things, but not WHAT you are trying to do. Not really enough info provided......

    Is the estimation form bound?
    How many check boxes are there on the form?
    Do you want to save the values or the total estimate or both?
    How often will the values change?

    I'm thinking the option group won't work. I would put the values in a table and use VBA to populate text boxes on the form.

  5. #5
    zero3ree is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2010
    Posts
    39
    I am still trying to figure out how to put it together. This was a conceptual idea. The main goal is to have a unbound form for the user to check some boxes and get a estimated amount of hours. I make bound it though so they can come back to it per project. Say the form would have 30 boxes that represent tasks that can be done. The user only does 5 so they check the 5 related boxes and predetermined hours for each task are summed up for a total hours to do the project.

  6. #6
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If you use checkboxes, you will need a companion control (textbox) that holds the value you want to add. This control does not have to be visible if that is preferred. Your query or code could sum the values of txtValue IF checkbox = true and your form can be bound to a table or query as you wish. However, I'm not sure how you'd associate the textbox to any given checkbox, unless maybe this is done on a continuous form. It should work in that case, as each checkbox and option button is associate with the same record. I suppose you could put the value in the control tag and add it from there as another method.

    If you use option buttons, you cannot place them in a frame because a frameset only allows one to be selected. You could place them within a rectangle that looks like a frame (etched border, transparent background) or just by themselves. You will have to loop through the form controls, looking for the option type of control, checking if selected and summing the default values as you go by writing something like:

    If Me.Option13.Value = True then intSum = intSum + Me.Option13.Defaultvalue

    Obviously you cannot refer to them by name in a loop. I'm just showing the properties you need to use. I guess you could also store the Option.Value in a table through code by writing 0 (false) or -1 (true) and read that value when re-opening the form (again, in code), but I don't think you can bind them.

  7. #7
    zero3ree is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2010
    Posts
    39
    I thought the option tool was a good canidate but I was not able to unselect the option. I need that flexibility like a checkbox has. What I ended up doing was adding the checkbox with the companion textbox like Micron mentioned. Then i added a sum textbox that only adds the hours if the checkbox is checked. This will work for what I am putting together. I thank all of you for your suggestions.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Adding Time Values
    By tennisbuck in forum Access
    Replies: 3
    Last Post: 10-07-2014, 07:26 PM
  2. Replies: 1
    Last Post: 07-31-2013, 06:31 PM
  3. Replies: 4
    Last Post: 05-14-2012, 10:15 AM
  4. Adding duplicate values in a query
    By mooseisloose in forum Queries
    Replies: 3
    Last Post: 04-14-2011, 12:12 PM
  5. Adding values to another field
    By GraemeG in forum Queries
    Replies: 0
    Last Post: 04-07-2011, 09:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums