Fill unbound text box from multiple user combo box selections

G

Guest

On a form, I have a combo box that the user selects an airport id. (The
airports table contains an airportid and an airportfacilityname.) Once the
user selects the airportid from the combo box, if it's the correct airport
that they want, they click a button, which loads the airportfacilityname to a
textbox called Itinerary.

I have the VB code for the button tied to the click event, and it works
perfectly, except that I need to allow for multiple combo box selects so that
the itinerary grows with what is selected. Based on the below code,
currently each combo box selection overwrites the previous itinerary text box
data.

The Itinerary should end up looking like:

Atlanta, GA; Norfolk, VA; Orlando, FL; etc....

Here's the code:

Private Sub clickAddtoItinerary_Click()

Dim varAirportCityState As Variant
Dim airport, completeitinerary As String

airport = Forms!frmairportidselect.frmLocID

varAirportCityState = DLookup("[FacilityCityState]", "AirportID", "[LocID] =
" & "'" & airport & "'")

completeitinerary = varAirportCityState & "; "
Me.AirportItinerary = completeitinerary

End Sub
 
G

Guest

Disregard.

I added the following and it works as needed:

If (IsNull(Me.AirportItinerary)) Then Me.AirportItinerary = completeitinerary

If (Not IsNull(Me.AirportItinerary)) Then Me.AirportItinerary =
Me.AirportItinerary & completeitinerary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top