Solved

Combo Box Puzzle

Posted on 2011-03-24
1
309 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

740 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