PC Review


Reply
Thread Tools Rate Thread

Combo Box/SQL statement

 
 
Monty
Guest
Posts: n/a
 
      30th May 2007
I have a combo box whose Row Source Type is table/query and Row Source
is "SELECT DISTINCT [Package Name] from Packages ORDER BY [Package
Name];". I can see the values when I run that SQL statement as a
query, but nothing shows up when I run it as a function of the form
(i.e., the form opens up, the SQL statement runs, but nothing shows up
in the combo box). I mean literally, nothing shows up, although I can
see there are the three place holders in the list I'm expecting, but
no text.

I'm wondering how much effect the Bound Column property has on this,
and frankly, from the help pages, I can't understand what it's
supposed to indicate. The Bound Column is currently 2--that's the
value Access put into it-- but I've tried it with 0 through 3 to no
effect.

What am I missing here?

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2VuIFNoZXJpZGFu?=
Guest
Posts: n/a
 
      30th May 2007
The BoundColumn property of a combo or list box is the column from which the
control takes its value when a selection is made. As in your case your SQL
statement only returns one column then it should be 1 not 2.

I also suspect that the ColumnWidths property might be incorrect. My guess
is that it is two dimensions with the first zero, which would be why you see
nothing because the first column is your one and only column, so if its width
is zero it will be hidden. Simply delete the entry for the ColumnWidths
property.

You might also find that the ColumnCount property is not 1. If so change it
to 1.

The sort of situation where you would hide the first column, set the
ColumnCount to 2 and the ColumnWidths to two dimensions of which the first is
zero, is when you want the value to be something like an arbitrary numeric ID
but you want to see the corresponding meaningful text value. Say for
instance you had a foreign key column CityID in a table, referencing the
primary key of a Cities table. A combo box bound to that column in a form
would have a RowSource:

SELECT CityID, City
FROM Cities
ORDER BY City;

Its BoundColumn property would be 1 so that the (unseen) value of the
control would be the CityID, its ColumnCount 2 as the SQL statement returns 2
columns, and its CoumnWidths something like 0cm;8cm to hide the CityID and
show just the city names.

Ken Sheridan
Stafford, England

"Monty" wrote:

> I have a combo box whose Row Source Type is table/query and Row Source
> is "SELECT DISTINCT [Package Name] from Packages ORDER BY [Package
> Name];". I can see the values when I run that SQL statement as a
> query, but nothing shows up when I run it as a function of the form
> (i.e., the form opens up, the SQL statement runs, but nothing shows up
> in the combo box). I mean literally, nothing shows up, although I can
> see there are the three place holders in the list I'm expecting, but
> no text.
>
> I'm wondering how much effect the Bound Column property has on this,
> and frankly, from the help pages, I can't understand what it's
> supposed to indicate. The Bound Column is currently 2--that's the
> value Access put into it-- but I've tried it with 0 through 3 to no
> effect.
>
> What am I missing here?
>
>


 
Reply With Quote
 
Monty
Guest
Posts: n/a
 
      30th May 2007
> I also suspect that the ColumnWidths property might be incorrect. My guess
> is that it is two dimensions with the first zero, which would be why you see
> nothing because the first column is your one and only column, so if its width
> is zero it will be hidden. Simply delete the entry for the ColumnWidths
> property.
>
> You might also find that the ColumnCount property is not 1. If so change it
> to 1.


That's exactly what it was, 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
For Next Statement with a Combo Box Owen Microsoft Word Document Management 7 27th Jul 2009 09:12 PM
If statement for a combo box Amber_D_Laws Microsoft Excel Programming 9 8th Feb 2006 10:26 PM
combo box if statement =?Utf-8?B?anIwMTI=?= Microsoft Access Form Coding 1 2nd Nov 2004 04:29 AM
Combo Box IF Statement =?Utf-8?B?SlIwMTI=?= Microsoft Access Form Coding 1 2nd Nov 2004 12:07 AM
Combo Box IF Statement =?Utf-8?B?SlIwMTI=?= Microsoft Access Form Coding 0 1st Nov 2004 11:52 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:50 PM.