Reference Combo Box Single Element

kcyankees125

Registered User.
Local time
Today, 04:16
Joined
Nov 20, 2012
Messages
11
I currently have a combo box called [DI_CONNECTION] set up on a form [Startup] that has a row source of: [ORIGIN] & " - " & [ORIGIN_TIME] & ", " & [DESTINATION] & " - " & [DESTINATION_TIME]

I would like to do a query that shows all records that have the same [DESTINATION] how do I reference just the [DESTINATION] in the query? I was taught the criteria should be in the form: [Forms]![Startup].[DI_CONNECTION] but do not know how to get to the specific [DESTINATION] of the record.
 
The criteria;
Code:
[Forms]![Startup]![DI_CONNECTION]

Will reference the Bound Column of the combo for the record that currently holds focus.
 
Normally you would have each field in a seperate column. To achieve your aim with the format you have, make a query to give you the concantenated field PLUS the Destination. The SQL would be something like;
Code:
SELECT TableName.[DESTINATION], TableName.[ORIGIN] & " - " & TableName.[ORIGIN_TIME] & ", " & TableName.[DESTINATION] & " - " & TableName.[DESTINATION_TIME] as Expr1 FROM TableName;

Then use this query as the control source of your combobox. Set the Columns to 2, column widths to 0;x and Bound Column to 1, which will then make [DESTINATION] the 'value' returned when referencing the combobox (eg with [Forms]![Startup].[DI_CONNECTION]).
 
You would have 4 columns in the combobox, and the row source would be something like;

SELECT TableName.[ORIGIN],TableName.[ORIGIN_TIME], TableName.[DESTINATION], TableName.[DESTINATION_TIME] FROM TableName;

The Bound Column would be 3 in this case ([DESTINATION] is the third column).
 
One last question, is there a way to reference multiple columns from that same combo box? I'd like one criteria to be based on the [DESTINATION] column and another criteria in the same query to be based on the [DESTINATION_TIME] column.
 
Yes, use the Columns() property of the combobox. So to reference [DESTINATION TIME] you would use [Forms]![Startup]![DI_CONNECTION].Columns(3). The reason you use (3) for the fourth column is that columns in a combo start at 0 - zero.
 
Actually, Access is giving me an error when I try to use that... an undefined function in expression error. Any idea why?
 

Users who are viewing this thread

Back
Top Bottom