PC Review


Reply
Thread Tools Rate Thread

Display only 1 column in listbox but return another

 
 
standish22@hotmail.com
Guest
Posts: n/a
 
      3rd Jan 2007
OK, I have a record set that has say the following rows

ID Description
----------------------------------------------
1 Apple
2 Book
3 Cat

***************************************************************************************
I have done the following code to populate the listbox
(Design view Properties)
BoundColumn = 1
ColumnCount = 2
TextColumn = 2

(Code)

Set RS = cmd.Execute
Me.lstPayCycles.Clear
Me.lstPayCycles.Column() = RS.GetRows

***************************************************************************************
When the form displays it displays the ID and Description. I've tried
everything to get only the description only to display. See I want to
display the description, but then retrieve the ID, when I need to use
it.

I've tried setting Column Count to 1: That displayed the ID's, even
though TextColumn = 2

Any ideas???

Thanks...

 
Reply With Quote
 
 
 
 
Nigel
Guest
Posts: n/a
 
      3rd Jan 2007
The bound column property determines the first column of data.

BoundColumn = 2
ColumnCount = 1

will show description only.


---------
Cheers
Nigel

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OK, I have a record set that has say the following rows
>
> ID Description
> ----------------------------------------------
> 1 Apple
> 2 Book
> 3 Cat
>
> ***************************************************************************************
> I have done the following code to populate the listbox
> (Design view Properties)
> BoundColumn = 1
> ColumnCount = 2
> TextColumn = 2
>
> (Code)
>
> Set RS = cmd.Execute
> Me.lstPayCycles.Clear
> Me.lstPayCycles.Column() = RS.GetRows
>
> ***************************************************************************************
> When the form displays it displays the ID and Description. I've tried
> everything to get only the description only to display. See I want to
> display the description, but then retrieve the ID, when I need to use
> it.
>
> I've tried setting Column Count to 1: That displayed the ID's, even
> though TextColumn = 2
>
> Any ideas???
>
> Thanks...
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      3rd Jan 2007
Keep column count = 2, but change the column width of one column to zero. In
the Properties window, for ColumnWidths, enter something like "90;0" without
the quotes, where the first column is 90 points wide and the second is zero.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> OK, I have a record set that has say the following rows
>
> ID Description
> ----------------------------------------------
> 1 Apple
> 2 Book
> 3 Cat
>
> ***************************************************************************************
> I have done the following code to populate the listbox
> (Design view Properties)
> BoundColumn = 1
> ColumnCount = 2
> TextColumn = 2
>
> (Code)
>
> Set RS = cmd.Execute
> Me.lstPayCycles.Clear
> Me.lstPayCycles.Column() = RS.GetRows
>
> ***************************************************************************************
> When the form displays it displays the ID and Description. I've tried
> everything to get only the description only to display. See I want to
> display the description, but then retrieve the ID, when I need to use
> it.
>
> I've tried setting Column Count to 1: That displayed the ID's, even
> though TextColumn = 2
>
> Any ideas???
>
> Thanks...
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      3rd Jan 2007
From the help file for TextColumn:

When the user selects a row from a ComboBox or ListBox, the column
referenced by TextColumn is stored in the Text property.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"John Bundy" <(E-Mail Removed)(remove)> wrote in message
news96A8BAC-DEA9-4988-B74B-(E-Mail Removed)...
>I think the textcolumn is where you are getting your problem, look it up in
> VBA help and it tells how to hide certain columns
> --
> -John Northwest11
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "(E-Mail Removed)" wrote:
>
>> OK, I have a record set that has say the following rows
>>
>> ID Description
>> ----------------------------------------------
>> 1 Apple
>> 2 Book
>> 3 Cat
>>
>> ***************************************************************************************
>> I have done the following code to populate the listbox
>> (Design view Properties)
>> BoundColumn = 1
>> ColumnCount = 2
>> TextColumn = 2
>>
>> (Code)
>>
>> Set RS = cmd.Execute
>> Me.lstPayCycles.Clear
>> Me.lstPayCycles.Column() = RS.GetRows
>>
>> ***************************************************************************************
>> When the form displays it displays the ID and Description. I've tried
>> everything to get only the description only to display. See I want to
>> display the description, but then retrieve the ID, when I need to use
>> it.
>>
>> I've tried setting Column Count to 1: That displayed the ID's, even
>> though TextColumn = 2
>>
>> Any ideas???
>>
>> Thanks...
>>
>>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      3rd Jan 2007
From help file on BoundColumn:

"Assigns the value from the specified column to the control."

This means the value from the selected row of the listbox and from the bound
column is what is stored as the .Value of the listbox.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Nigel" <nigel-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The bound column property determines the first column of data.
>
> BoundColumn = 2
> ColumnCount = 1
>
> will show description only.
>
>
> ---------
> Cheers
> Nigel
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> OK, I have a record set that has say the following rows
>>
>> ID Description
>> ----------------------------------------------
>> 1 Apple
>> 2 Book
>> 3 Cat
>>
>> ***************************************************************************************
>> I have done the following code to populate the listbox
>> (Design view Properties)
>> BoundColumn = 1
>> ColumnCount = 2
>> TextColumn = 2
>>
>> (Code)
>>
>> Set RS = cmd.Execute
>> Me.lstPayCycles.Clear
>> Me.lstPayCycles.Column() = RS.GetRows
>>
>> ***************************************************************************************
>> When the form displays it displays the ID and Description. I've tried
>> everything to get only the description only to display. See I want to
>> display the description, but then retrieve the ID, when I need to use
>> it.
>>
>> I've tried setting Column Count to 1: That displayed the ID's, even
>> though TextColumn = 2
>>
>> Any ideas???
>>
>> Thanks...
>>

>
>



 
Reply With Quote
 
Nigel
Guest
Posts: n/a
 
      4th Jan 2007
That was my point, if you need to display column 2 (The Description) set the
BoundColumn to 2. I accept it does not answer the OPs other quest to return
the ID #.

--
Cheers
Nigel



"Jon Peltier" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> From help file on BoundColumn:
>
> "Assigns the value from the specified column to the control."
>
> This means the value from the selected row of the listbox and from the
> bound column is what is stored as the .Value of the listbox.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Nigel" <nigel-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> The bound column property determines the first column of data.
>>
>> BoundColumn = 2
>> ColumnCount = 1
>>
>> will show description only.
>>
>>
>> ---------
>> Cheers
>> Nigel
>>
>> <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> OK, I have a record set that has say the following rows
>>>
>>> ID Description
>>> ----------------------------------------------
>>> 1 Apple
>>> 2 Book
>>> 3 Cat
>>>
>>> ***************************************************************************************
>>> I have done the following code to populate the listbox
>>> (Design view Properties)
>>> BoundColumn = 1
>>> ColumnCount = 2
>>> TextColumn = 2
>>>
>>> (Code)
>>>
>>> Set RS = cmd.Execute
>>> Me.lstPayCycles.Clear
>>> Me.lstPayCycles.Column() = RS.GetRows
>>>
>>> ***************************************************************************************
>>> When the form displays it displays the ID and Description. I've tried
>>> everything to get only the description only to display. See I want to
>>> display the description, but then retrieve the ID, when I need to use
>>> it.
>>>
>>> I've tried setting Column Count to 1: That displayed the ID's, even
>>> though TextColumn = 2
>>>
>>> Any ideas???
>>>
>>> Thanks...
>>>

>>
>>

>
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      4th Jan 2007
That's not how it works. If you need to display column 2, make sure you
specify that column 2 has a nonzero width. If you don't want to also display
column 1, make sure column 1 has a width of zero.

BoundColumn indicates which column of the listbox is returned when you query
ListBox1.Value. If BoundColumn is 1 or omitted, .Value returns what's in the
first column of the selected row. If BoundColumn is 2, it returns what's in
the second column of the selected row.

Similarly with TextColumn, which indicates which column of the listbox is
returned when you query ListBox1.Text. If TextColumn is 1, .Text returns
what's in the first column of the selected row. If TextColumn is 2, it
returns what's in the second column of the selected row.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Nigel" <nigel-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> That was my point, if you need to display column 2 (The Description) set
> the BoundColumn to 2. I accept it does not answer the OPs other quest to
> return the ID #.
>
> --
> Cheers
> Nigel
>
>
>
> "Jon Peltier" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> From help file on BoundColumn:
>>
>> "Assigns the value from the specified column to the control."
>>
>> This means the value from the selected row of the listbox and from the
>> bound column is what is stored as the .Value of the listbox.
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://PeltierTech.com
>> _______
>>
>>
>> "Nigel" <nigel-(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> The bound column property determines the first column of data.
>>>
>>> BoundColumn = 2
>>> ColumnCount = 1
>>>
>>> will show description only.
>>>
>>>
>>> ---------
>>> Cheers
>>> Nigel
>>>
>>> <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> OK, I have a record set that has say the following rows
>>>>
>>>> ID Description
>>>> ----------------------------------------------
>>>> 1 Apple
>>>> 2 Book
>>>> 3 Cat
>>>>
>>>> ***************************************************************************************
>>>> I have done the following code to populate the listbox
>>>> (Design view Properties)
>>>> BoundColumn = 1
>>>> ColumnCount = 2
>>>> TextColumn = 2
>>>>
>>>> (Code)
>>>>
>>>> Set RS = cmd.Execute
>>>> Me.lstPayCycles.Clear
>>>> Me.lstPayCycles.Column() = RS.GetRows
>>>>
>>>> ***************************************************************************************
>>>> When the form displays it displays the ID and Description. I've tried
>>>> everything to get only the description only to display. See I want to
>>>> display the description, but then retrieve the ID, when I need to use
>>>> it.
>>>>
>>>> I've tried setting Column Count to 1: That displayed the ID's, even
>>>> though TextColumn = 2
>>>>
>>>> Any ideas???
>>>>
>>>> Thanks...
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      6th Jan 2007
Since Jon did not name to property explicitly:

> If you need to display column 2, make sure you specify that column 2 has a
> nonzero width. If you don't want to also display column 1, make sure
> column 1 has a width of zero.


which of course is done with the columnWidths property

me.Listbox1.columnWidths = 90;0

would hide the second column as an example.

Making the second column the boundcolumn would return the value from that
column for the value property as Jon stated.

--
Regards,
Tom Ogilvy


"Jon Peltier" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> That's not how it works. If you need to display column 2, make sure you
> specify that column 2 has a nonzero width. If you don't want to also
> display column 1, make sure column 1 has a width of zero.
>
> BoundColumn indicates which column of the listbox is returned when you
> query ListBox1.Value. If BoundColumn is 1 or omitted, .Value returns
> what's in the first column of the selected row. If BoundColumn is 2, it
> returns what's in the second column of the selected row.
>
> Similarly with TextColumn, which indicates which column of the listbox is
> returned when you query ListBox1.Text. If TextColumn is 1, .Text returns
> what's in the first column of the selected row. If TextColumn is 2, it
> returns what's in the second column of the selected row.
>
> - Jon
> -------
> Jon Peltier, Microsoft Excel MVP
> Tutorials and Custom Solutions
> http://PeltierTech.com
> _______
>
>
> "Nigel" <nigel-(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> That was my point, if you need to display column 2 (The Description) set
>> the BoundColumn to 2. I accept it does not answer the OPs other quest to
>> return the ID #.
>>
>> --
>> Cheers
>> Nigel
>>
>>
>>
>> "Jon Peltier" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> From help file on BoundColumn:
>>>
>>> "Assigns the value from the specified column to the control."
>>>
>>> This means the value from the selected row of the listbox and from the
>>> bound column is what is stored as the .Value of the listbox.
>>>
>>> - Jon
>>> -------
>>> Jon Peltier, Microsoft Excel MVP
>>> Tutorials and Custom Solutions
>>> http://PeltierTech.com
>>> _______
>>>
>>>
>>> "Nigel" <nigel-(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> The bound column property determines the first column of data.
>>>>
>>>> BoundColumn = 2
>>>> ColumnCount = 1
>>>>
>>>> will show description only.
>>>>
>>>>
>>>> ---------
>>>> Cheers
>>>> Nigel
>>>>
>>>> <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> OK, I have a record set that has say the following rows
>>>>>
>>>>> ID Description
>>>>> ----------------------------------------------
>>>>> 1 Apple
>>>>> 2 Book
>>>>> 3 Cat
>>>>>
>>>>> ***************************************************************************************
>>>>> I have done the following code to populate the listbox
>>>>> (Design view Properties)
>>>>> BoundColumn = 1
>>>>> ColumnCount = 2
>>>>> TextColumn = 2
>>>>>
>>>>> (Code)
>>>>>
>>>>> Set RS = cmd.Execute
>>>>> Me.lstPayCycles.Clear
>>>>> Me.lstPayCycles.Column() = RS.GetRows
>>>>>
>>>>> ***************************************************************************************
>>>>> When the form displays it displays the ID and Description. I've tried
>>>>> everything to get only the description only to display. See I want to
>>>>> display the description, but then retrieve the ID, when I need to use
>>>>> it.
>>>>>
>>>>> I've tried setting Column Count to 1: That displayed the ID's, even
>>>>> though TextColumn = 2
>>>>>
>>>>> Any ideas???
>>>>>
>>>>> Thanks...
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Jon Peltier
Guest
Posts: n/a
 
      7th Jan 2007
Tom -

Thanks for clarifying.

Jon Peltier, Microsoft Excel MVP
http://PeltierTech.com


"Tom Ogilvy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Since Jon did not name to property explicitly:
>
>> If you need to display column 2, make sure you specify that column 2 has
>> a nonzero width. If you don't want to also display column 1, make sure
>> column 1 has a width of zero.

>
> which of course is done with the columnWidths property
>
> me.Listbox1.columnWidths = 90;0
>
> would hide the second column as an example.
>
> Making the second column the boundcolumn would return the value from that
> column for the value property as Jon stated.
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Jon Peltier" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> That's not how it works. If you need to display column 2, make sure you
>> specify that column 2 has a nonzero width. If you don't want to also
>> display column 1, make sure column 1 has a width of zero.
>>
>> BoundColumn indicates which column of the listbox is returned when you
>> query ListBox1.Value. If BoundColumn is 1 or omitted, .Value returns
>> what's in the first column of the selected row. If BoundColumn is 2, it
>> returns what's in the second column of the selected row.
>>
>> Similarly with TextColumn, which indicates which column of the listbox is
>> returned when you query ListBox1.Text. If TextColumn is 1, .Text returns
>> what's in the first column of the selected row. If TextColumn is 2, it
>> returns what's in the second column of the selected row.
>>
>> - Jon
>> -------
>> Jon Peltier, Microsoft Excel MVP
>> Tutorials and Custom Solutions
>> http://PeltierTech.com
>> _______
>>
>>
>> "Nigel" <nigel-(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> That was my point, if you need to display column 2 (The Description) set
>>> the BoundColumn to 2. I accept it does not answer the OPs other quest
>>> to return the ID #.
>>>
>>> --
>>> Cheers
>>> Nigel
>>>
>>>
>>>
>>> "Jon Peltier" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> From help file on BoundColumn:
>>>>
>>>> "Assigns the value from the specified column to the control."
>>>>
>>>> This means the value from the selected row of the listbox and from the
>>>> bound column is what is stored as the .Value of the listbox.
>>>>
>>>> - Jon
>>>> -------
>>>> Jon Peltier, Microsoft Excel MVP
>>>> Tutorials and Custom Solutions
>>>> http://PeltierTech.com
>>>> _______
>>>>
>>>>
>>>> "Nigel" <nigel-(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> The bound column property determines the first column of data.
>>>>>
>>>>> BoundColumn = 2
>>>>> ColumnCount = 1
>>>>>
>>>>> will show description only.
>>>>>
>>>>>
>>>>> ---------
>>>>> Cheers
>>>>> Nigel
>>>>>
>>>>> <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> OK, I have a record set that has say the following rows
>>>>>>
>>>>>> ID Description
>>>>>> ----------------------------------------------
>>>>>> 1 Apple
>>>>>> 2 Book
>>>>>> 3 Cat
>>>>>>
>>>>>> ***************************************************************************************
>>>>>> I have done the following code to populate the listbox
>>>>>> (Design view Properties)
>>>>>> BoundColumn = 1
>>>>>> ColumnCount = 2
>>>>>> TextColumn = 2
>>>>>>
>>>>>> (Code)
>>>>>>
>>>>>> Set RS = cmd.Execute
>>>>>> Me.lstPayCycles.Clear
>>>>>> Me.lstPayCycles.Column() = RS.GetRows
>>>>>>
>>>>>> ***************************************************************************************
>>>>>> When the form displays it displays the ID and Description. I've
>>>>>> tried
>>>>>> everything to get only the description only to display. See I want
>>>>>> to
>>>>>> display the description, but then retrieve the ID, when I need to use
>>>>>> it.
>>>>>>
>>>>>> I've tried setting Column Count to 1: That displayed the ID's, even
>>>>>> though TextColumn = 2
>>>>>>
>>>>>> Any ideas???
>>>>>>
>>>>>> Thanks...
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox Column Display Francis Ang Microsoft Excel Programming 3 6th Oct 2009 01:04 AM
Textbox to display Listbox 2nd column value Corey Microsoft Excel Programming 3 30th Jul 2009 03:44 AM
How do I return the unique entries from a column to a listbox Dave Mc Microsoft Excel Worksheet Functions 4 9th Feb 2005 08:02 AM
Display of percent column in listbox ? David Microsoft Access Forms 0 10th Dec 2003 05:28 PM
Re: Tel display mask in Listbox column Ken Snell Microsoft Access Form Coding 3 19th Jul 2003 01:54 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 PM.