Results 1 to 12 of 12
  1. #1
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41

    Use Values Selected From Combo Box in Form to Run Calculation in Query

    Hello,

    I have been working in MS Access for the past few weeks, but I have very little experience with queries. Here is what I am trying to do:



    I have 3 fields with combo boxes on a form and each combo box has three choices: High, Medium, and Low.

    I would like to establish a numerical value with each field depending on what is selected. For instance, High=5, Medium=3, Low=1.

    I plan on taking the 3 fields and using the selected values in a calculation that would generate a score and I would like to store this value on a table.

    My question for you guys is; is there any information you could send my way that can assist with the development of this?

    Here is a picture of what I am reffering to on my form:

    Click image for larger version. 

Name:	1.PNG 
Views:	14 
Size:	4.5 KB 
ID:	17657

    Thanks in advance!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Some here may prefer to use a Value List for the combo box in instances like this. My preference is to use tables and have the Combo Boxes Row Sources look to the tables. I would create a table for each of the Combo Boxes/factors, Probability, Severity, etc. Each table would have a column for the description and a column for the Primary Key.

  3. #3
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41
    Any idea on how I can assign the numbers based on the ranking selected?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    You could use a bound control as a combo's Control Source. Another option is to use SQL and or DAO to update/append records.

  5. #5
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    Since you are drawing those combo box values from somewhere, I would draw them from a table and have each table set up like this:

    Probability_Table
    ______________________________________________
    [ID] (#field)..........[Rating]
    5.........................High
    3.........................Medium
    1.........................Low

    And then do the same for the Severity and Detection tables, etc...

    This way, if "High" is selected, it automatically corresponds to the number 5 - etc...for each table.


    Give each table a unique reference ID (the same as the value if you don't want to get confused)

    Now, on your Main table where you keep the records, set up 3 (or however many you need) fields where you can create a relationship with the other tables you just created. Call the fields ProbabilityMain, SeverityMain, DetectionMain and you'll see the user input for the text values. Make sure that you have a number field in your table left blank for the time being called "SumMain" or something.

    Now, create a query. In particular, create an UPDATE QUERY.

    Call upon your main table and whatever other tables you created and join them.

    Run the query for the Values in the main table and then also run the ID fields in the other tables you created. You'll see that if you run the query, for each record, High matches with 5, Medium with 3, etc...

    Then call upon the SumMain field in your main table. Under the UPDATE TO criteria below - put

    =SUM([ProbabilityTable].[ID], [SeverityTable].[ID], etc...)

    It will update the SumMain field with all the values you want.



    It is important to note that the update query must be ran regularly to make sure that the values in the SumMain field are indeed there. For report or whatever purposes.

  6. #6
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41
    I am going to try and restate my issue, because I can't seem to find anything out there on what I want to do.

    I have a Field with a combo box on a form containing 3 values, "High", "Medium", and "Low". Depending on what the user selects, I would like to populate another field with an integer and use that integer in a calculation.

    How can I do this? Thanks

  7. #7
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41
    Thank you! just saw that I recieved replies while I was typing. haha

  8. #8
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    Let me know if you have issues - but it should work.

  9. #9
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41
    While I am giving this a try, my combo boxes are now displaying 1,3,and 5 instead of Low, Medium, and High. What am I doing worng?

  10. #10
    McArthurGDM is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    215
    When you create the combo box, make sure it's on the wizard. You can call upon the particular field (High, Medium, Low) for each table. You can choose to turn off or on the ID field in that case.

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If you are saving the number value, maybe you need multi-column combobox. Review http://www.datapigtechnologies.com/f...combobox3.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  12. #12
    ZachAtaiyan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2014
    Posts
    41
    I don't really know how, but I got it to work. I didn't even have to use the query, just the Combobox wizard. Thanks again!

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

Similar Threads

  1. Replies: 5
    Last Post: 04-24-2014, 10:02 AM
  2. Replies: 1
    Last Post: 12-29-2013, 11:21 AM
  3. Replies: 12
    Last Post: 04-18-2011, 08:52 AM
  4. Replies: 0
    Last Post: 03-08-2011, 05:56 PM
  5. Replies: 1
    Last Post: 03-27-2010, 06:13 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