Re: Setting a ListBox value Programmatically?

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Gary Schuldt (garyschuldt_at_comcast.net)
Date: 02/19/04


Date: Thu, 19 Feb 2004 13:34:29 -0800

Thanks, Kelvin. I now am clear that it's the bound column that controls the
display.

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

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

"Kelvin" <klu@klu.com> wrote in message
news:eslDgDy9DHA.1948@TK2MSFTNGP12.phx.gbl...
> Combo boxes and list boxes are all controlled by the bound column
regardless
> of what data is shown. So if you want to set the selected item in the
list,
> set the value of the list to the value of the bound column. In your case
it
> would be the ID.
>
> Kelvin
>
> "Gary Schuldt" <garyschuldt@comcast.net> wrote in message
> news:uRhNonx9DHA.488@TK2MSFTNGP12.phx.gbl...
> > I have a lstboxControl based on the first 3 columns of a table tForm.
The
> > listbox displays only the 2nd column (the name; the ID is the first
> column).
> >
> > Normally the user clicks on the desired value. However, there's a
> situation
> > in which I can logically determine the proper value from some other
coding
> > in the form (CBF).
> >
> > Is it possible to set the value for the lstboxControl in that way?
Which
> > Column value do I set . . . the ID, or the one that's displayed? I
don't
> > have a good sense for what to do here.
> >
> > Thanks for the help, as always.
> >
> > Gary
> >
> >
>
>



Relevant Pages

  • Re: multiple key fields in parent table and combo boxes for foreign ke
    ... PK1 and PK2 are primary key fields in Table 1. ... I set the Lookup Display Control to Combo Box for the foreign key fields ... Row Source and retain the default Bound Column value of 1. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Combo goes blank on form requery
    ... There's a valid case where the combo's Bound Column is not its display column, and the RowSource is filtered in such a way that it does not have the record it needs to display. ... If the combo is selected, the selection may even be the width of the characters, but the characters are not visible. ... On a simple bound continuous form I have a combo for filtering the form by customer. ...
    (comp.databases.ms-access)
  • Re: Combo Box problems
    ... the same value as another and have it display the correct item. ... isn't equal to the bound column. ... the price * Qty value and display it in this field. ...
    (microsoft.public.access.forms)
  • RE: ComboBox Parameter Problem
    ... The bound column does not need to be visible to be used. ... the first column does not have to be ... > of 0 means the column will not display. ... >> column that needs to be picked up in the parameter query. ...
    (microsoft.public.access.forms)
  • Re: Combo Box List
    ... > in your row source. ... > Note that you can not display two fields as the value of the combobox after ... > width is not 0 or if the Bound Column property is greater than that column ... the bound column is displayed. ...
    (microsoft.public.access.formscoding)