Select Item in Listbox

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I'm trying to select a record in a listbox based on the value of a field
on a form. I thought this would work but it doesn't. Any help appreciated.
Thanks
DS

Forms!AdjustTime!ListLogs.Item = Forms!AdjustTime!TxtLogID
 
Dear DS:

Is there a reason why the listbox control is not bound to the column?

Otherwise, you would probably have to use the Current event to scan through
the values in the list box and select the current one. That would be a lot
of unnecessary coding if it could just be bound.

Tom Ellison
 
Tom said:
Dear DS:

Is there a reason why the listbox control is not bound to the column?

Otherwise, you would probably have to use the Current event to scan through
the values in the list box and select the current one. That would be a lot
of unnecessary coding if it could just be bound.

Tom Ellison
Tom,
The Listbox can't be bound because the listbox can be anyone of three
different set of records. I just need to select the record that is in
the field. Thanks
DS
 
Dear DS:

I presume that, no matter which "set of records" is reflected in the list
box, the one that is "in the field" will be in the list. Otherwise, you
could not select it. It sounds like the RowSource of the Listbox may vary,
but the key to the selected row in the Listbox would still be a column in
the form's Recordsource.

While I have never run into this, it would still seem possible to have the
control be bound, but with a variable Rowsource.

If there is a reason why this doesn't work, then perhaps by making the
suggestion I can learn why it doesn't work and that may help me understand
the problem and search for a solution.

Tom Ellison
 
Tom said:
Dear DS:

I presume that, no matter which "set of records" is reflected in the list
box, the one that is "in the field" will be in the list. Otherwise, you
could not select it. It sounds like the RowSource of the Listbox may vary,
but the key to the selected row in the Listbox would still be a column in
the form's Recordsource.

While I have never run into this, it would still seem possible to have the
control be bound, but with a variable Rowsource.

If there is a reason why this doesn't work, then perhaps by making the
suggestion I can learn why it doesn't work and that may help me understand
the problem and search for a solution.

Tom Ellison
Your right, no matter what the lists records are it will always have the
TxtLogID in the list. And always in the same column. So, the code I
posted earlier, will it work with some tweaking?
Thanks
DS
 
Dear DS:

Seriously, I don't know if the code will work. It would depend not only on
the code, but where you put it. It would have to be executed whenever it is
needed.

Have you tried my suggestion. Make the control bound to that column.
Change the RowSource of the list box when needed.

Tom Ellison
 
Tom said:
Dear DS:

Seriously, I don't know if the code will work. It would depend not only on
the code, but where you put it. It would have to be executed whenever it is
needed.

Have you tried my suggestion. Make the control bound to that column.
Change the RowSource of the list box when needed.

Tom Ellison
Ok, how would I bind the control to the column?
Thanks
DS
 
Dear DS:

Any control may be bound to a column in the form's RecordSource. Surely you
have done this many times. The control's ControlSource property brings up a
list of the columns in the form's RecordSource. Pick one.

Tom Ellison
 
Tom said:
Dear DS:

Any control may be bound to a column in the form's RecordSource. Surely you
have done this many times. The control's ControlSource property brings up a
list of the columns in the form's RecordSource. Pick one.

Tom Ellison
Yeah your right, sometimes after many hours of work you get brain dead
and can't see the forrest for the trees !!!

That didn't really work though.
Thanks
DS
 

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

Back
Top