?
Solved

Combo Box Puzzle

Posted on 2011-03-24
1
Medium Priority
?
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

719 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