See below.
Gary Schuldt said:
Thanks, Kelvin. I now am clear that it's the bound column that controls the
display.
Not quite. The bound column controls what is stored in the table. The rest
is looked up based on what is stored. For example, if Bob Smith's ID is 515
and the bound column is his ID. The table will actually store 515, but
based on how you define the rest of the select statement it may show 515,
Bob, or Mr. Smith. The important thing is 515.
The listboxControl's row source is a query:
SELECT tForm.FormID, tForm.FormName, tForm.DisplayFormName FROM tForm
The bound column is 1, displayed is 2
So if I execute the statement
Me.lstboxControl.Column(0) = 7
No. The .Column(#) is a read only used to find the rest of the data that is
not shown for the chosen item in the list. In your example you have 3
fields: FormID, FormName, and DisplayFormName. .Column(0) refers to FormID,
.Column(1) refers to FormName and .Column(2) refers to DisplayFormName. You
can set other things to equal this value but not the other way around. So
if you had an unbound text box on your form called "Name Of Form" you can
set the contents of this text box to equal any of the items from the combo
box.
[Name Of Form] = listboxControl.Column(0) will set the content of Name Of
Form to equal FormID of the selected item.
[Name Of Form] = listboxContro.Column(1) will set to FormName
[Name Of Form] = listboxControl.Column(2) will set to DisplayFormName
from somehwhere else in the main form code, what actually is happening
behind the scenes of the form? Does the current record in tForm become the
one whose ID = 7 and then lstboxControl is populated with that row, so that
Column(1) contains tForm.FormName and that's what is displayed and
highlighted?
That's definitely what I want the result to be!
Gary
If you want to set the chosen selection to something you need to change the
value of the combo box, not one of the fields from the current selection.
Me.listboxControl = 7
will set listboxControl to 7. If there is a FormID 7 then this will be the
current selection for the combo box and FormName will be shown.
Kelvin