Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating list for combo box using multiple fields from current record

Status
Not open for further replies.

tvsmvp

Technical User
Aug 17, 2006
59
US
I would like to add a combo box to my form. I have four fields (in each record, naturally) that I would like to offer in that drop down box. That is, I've entered a single city into each of 3 or 4 fields and want a drop down that offers those three/four cities for selection (as opposed to a dropdown that lists all cities for all records.

The following attempt gets me all the cities for all the records (but, as said, I just want the cities from the current record):
SELECT [City] FROM [Facilities] UNION SELECT [ReferenceCity1] FROM [Facilities] UNION SELECT [ReferenceCity2] FROM [Facilities] ORDER BY [City];

Any ideas?
 
Hi, try this:

Private Sub Combo5_Enter()

Dim city1, city2, city3, city4, stSql As String

city1 = Me.txtCity1
city2 = Me.txtCity2
city3 = Me.txtCity3
city4 = Me.txtCity4

stSql = Me.txtCity1 & ";" & Me.txtCity2 & ";" & Me.txtCity3 & ";" & Me.txtCity4

Me.Combo5.RowSource = stSql

End Sub

Hope that helps
 
Why do you assign the controls to variables ("city1") and then not use them? Did you mean to use them in that "stSql" line?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top