By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,451 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Combobox

100+
P: 173
Hi,

a simple one...........

i have a combobox with a list of line providers....... (from table tab_data).....

BT is one of the providers...........

In the list it shows BT several times, how can i limit this to one? i dont want replica data in the list............
Jan 8 '07 #1
Share this Question
Share on Google+
5 Replies


nico5038
Expert 2.5K+
P: 3,072
The problem of this lies in the data in your table, let's assume the table look like:
1 BT
2 XYZ
3 BT
Then BT will appear 2 times. I would have define a unique index on the company name, to prevent that users enter the same company twice. When you have this in your table you have two options:
1 Qualify the names to make them unique like:
1 BT World Wide
2 XYZ
3 BT US
2 Use a GroupBy query, but then you need to decide which code to use like:
select Max(code), company from tab_X group by company
that gives for yor combo:
2 XYZ
3 BT
Or
select Min(code), company from tab_X group by company
Giving:
1 BT
2 XYZ
It's not possible to have two values for one field in a GroupBy....

Nic;o)
Jan 8 '07 #2

NeoPa
Expert Mod 15k+
P: 31,186
In a QueryDef, if you look at the properties of the QueryDef itself, you will see Unique Values and Unique Records. These can also be used to remove duplicates from a simple SELECT type query.
Jan 9 '07 #3

Expert 5K+
P: 8,435
In a QueryDef, if you look at the properties of the QueryDef itself, you will see Unique Values and Unique Records. These can also be used to remove duplicates from a simple SELECT type query.
But how do you put them in an SQL string?
Jan 9 '07 #4

hariharanmca
100+
P: 1,977
Hi,

a simple one...........

i have a combobox with a list of line providers....... (from table tab_data).....

BT is one of the providers...........

In the list it shows BT several times, how can i limit this to one? i dont want replica data in the list............

then use the distinct QRY Like

========================QRY======================


strSql="Select distinct FieldName from TableName"
Jan 9 '07 #5

NeoPa
Expert Mod 15k+
P: 31,186
then use the distinct QRY Like

========================QRY======================


strSql="Select distinct FieldName from TableName"
That's right - You can use the DISTINCT and DISTINCTROW predicates within the SELECT clause.
Jan 9 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.