Solved

Combo Box Puzzle

Posted on 2011-03-24
1
303 Views
Last Modified: 2012-05-11
Hi,

I have a tricky problem to solve, which I’m a bit stuck on.

I have combo box which has numerical value within the first column. (cbo_1).

Under this I have 4 further combo boxes. (cbo_2 -> cbo_5)

The idea is that a user makes a choice from the cbo_1 control.  For this example say its 10. The 10 have to be assigned to any of the other 4 combo controls.

So far I have set the change event of cbo_1 to populate each of the 4 controls which the value of cbo_1

I use this code:

For i = 1 To Forms!fdlgInspection.cbo_1.Column(1)
  sRS = sRS & "," & CStr(i)
Next i

Forms!fdlgInspection.cbo_2.RowSource = Right(sRS, Len(sRS) - 1)
Forms!fdlgInspection.cbo_3.RowSource = Right(sRS, Len(sRS) - 1)
Forms!fdlgInspection.cbo_4.RowSource = Right(sRS, Len(sRS) - 1)
Forms!fdlgInspection.cbo_5.RowSource = Right(sRS, Len(sRS) - 1)

This is where I’m stuck.  If for example the user selects 4 from any of the above controls then I would like the remaining 3 to have the values reset so the maximum they can choose is 6.  Basically no matter what selection is made (in whichever order the grand total of the controls can never exceed the value held within Forms!fdlgInspection.cbo_1.Column(1).

Is this even achievable?  Any suggestions much appreciated.
0
Comment
Question by:andyw27
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 35208218
you can try this


Private Sub cbo_2_AfterUpdate()
sRS = ""
For i = 1 To Forms!fdlgInspection.cbo_1.Column(1) - Forms!fdlgInspection.cbo_2.Column(0)
  sRS = sRS & "," & CStr(i)
Next i
Forms!fdlgInspection.cbo_3.RowSource = Right(sRS, Len(sRS) - 1)
Forms!fdlgInspection.cbo_4.RowSource = Right(sRS, Len(sRS) - 1)
Forms!fdlgInspection.cbo_5.RowSource = Right(sRS, Len(sRS) - 1)

End Sub
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question