cascading combo boxes

  • Thread starter Thread starter Afrosheen
  • Start date Start date
A

Afrosheen

I have a cascading combo box that works good. My boss wants me to combine two
fields into one. Here is the code I have now to create the combo box.

'---------------------------------------------------------------------------------------
' Procedure : grpcountry_AfterUpdate
' Author :
' Date : 6/22/2008
' Purpose : Mixed controls for a cascading combo bo
'---------------------------------------------------------------------------------------
'
Private Sub grpcountry_AfterUpdate()
On Error Resume Next
Dim strcnt As String
Select Case grpcountry.Value
Case 1
strcnt = "Support Services"
Case 2
strcnt = "Administration"
Case 3
strcnt = "Admin Support"
Case 4
strcnt = "Medical"
Case 5
strcnt = "Opps"
Case 6
strcnt = "Unit 1"
Case 7
strcnt = "Unit 2"
Case 8
strcnt = "Unit 3"
Case 9
strcnt = "Unit 4"
Case 10
strcnt = "Maintenance"
End Select

cboloc.RowSource = "Select tbl_assignment.locat, tbl_assignment.unit,
tbl_assignment.pull " & _
"From tbl_assignment " & _
"Where tbl_assignment.locat = '" & strcnt & "' " & _
"Order by tbl_assignment.unit;"

End Sub

What it display is the unit for example, if I select unit 3 from the Option
Group it picks out all the information pertaining from Unit 3. Like "Control
Room", "A Block" etc.
The table this information comes from has 3 fields. Unit, Pull, and Locat.

What I want is to combine {with in programming} the Unit and Pull so instead
of having it read:
U1 Control {which is the "Unit" field}

it would read:

U1 Control P3 {This would be the combo of the Unit and Pull together}

I hope I've explained my self.
 
Not sure what the bound control of your combo is, so you don't want to mess
with that. But in your combo's row source query, you could use a calculated
field to present the two values

"Select tbl_assignment.locat, tbl_assignment.unit & " " &
tbl_assignment.pull As UnitPull" & _
"From tbl_assignment " & _
"Where tbl_assignment.locat = '" & strcnt & "' " & _
"Order by tbl_assignment.unit;"
 
Back
Top