Solved

# Combo Box Puzzle

Posted on 2011-03-24
276 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
Question by:andyw27
1 Comment

LVL 119

Accepted Solution

Rey Obrero 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

## Join & Write a Comment Already a member? Login.

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

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

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

#### Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!