Capturing the text from a Combo Box

  • Thread starter Thread starter Pat
  • Start date Start date
P

Pat

Hi All,

This is my first post here, and this is probably a very noobish
question, but I've been searching for hours and really need to solve
this problem.

I'm working on a project for work where given an origin and a
destination I need to return the distance between the two points. I've
been supplied with a table containing (believe it or not) every
possible combination of origins and destinations that I would ever
need, and their respective distances apart.

I've created a form with two combo boxes in it, one combo is populating
from the origin column of the table, and the other from the destination
column. This form also includes a command button that executes a query
that I have a query set to return the mileage value if provided the
origin and destination:

The query is set up like:
[Forms]![frmMileage]![combo_From]
[Forms]![frmMileage]![combo_To]

My issue is that the query (when run from the form) never returns ANY
information. It works fine however, if run directly as a query (and I
key in the information).

After some debugging I discovered that the problem is that the combo
boxes are passing the integer index values to the query and not the
STRING of the selected item.

Is there a way to capture these two string values (origin and
destination) and pass them to the query?

I reallllly appreciate anyone who is willing to help me out here.
--Pat
 
For some reason I mistyped this paragraph... sorry for the confusion:

My issue is that the query (when run from the form) never returns NO
information. It works fine however, if run directly as a query (and I
key in the information).
 
Pat said:
Hi All,

This is my first post here, and this is probably a very noobish
question, but I've been searching for hours and really need to solve
this problem.

I'm working on a project for work where given an origin and a
destination I need to return the distance between the two points. I've
been supplied with a table containing (believe it or not) every
possible combination of origins and destinations that I would ever
need, and their respective distances apart.

I've created a form with two combo boxes in it, one combo is populating
from the origin column of the table, and the other from the destination
column. This form also includes a command button that executes a query
that I have a query set to return the mileage value if provided the
origin and destination:

The query is set up like:
[Forms]![frmMileage]![combo_From]
[Forms]![frmMileage]![combo_To]

My issue is that the query (when run from the form) never returns ANY
information. It works fine however, if run directly as a query (and I
key in the information).

After some debugging I discovered that the problem is that the combo
boxes are passing the integer index values to the query and not the
STRING of the selected item.

Is there a way to capture these two string values (origin and
destination) and pass them to the query?

I reallllly appreciate anyone who is willing to help me out here.
--Pat

On your ComboBox change the BoundColumn from (1) to (2).
 
to change a combo box control's BoundColumn property:

open the form in design view.
click once on the combo box control to select it.
if the Properties box is not open, press Alt+Enter to open it.
click the Data tab in the Properties box.
the BoundColumn property is about the fifth one on the list; its' default
value is 1, change it to 2.

hth
 
Back
Top