Topic: Distinct

Hi,
can I use the command DISTINCT in a combobox ?
What I wanna do is to show in the combobox records from a table, but if there are the same record it should be only ones.
Thank's in advance

Re: Distinct

Hello,

You can use method dbSQLExecute


Can fill the component the resulting of SQL query.


Note that in SQL query is a field "id", the component could know what records in the database belongs to the selected item.


Example:

 Form1.ComboBox1.dbSQLExecute ('SELECT DISTINCT fieldname, id FROM tablename');
Dmitry.

3 (edited by v_pozidis 2016-01-14 07:59:39)

Re: Distinct

Hi,
I have add the script in the ComboBox but it doesn't work
I attache my example in here so you could have a better look.
Thank you in advance

Post's attachments

Attachment icon distinct.zip 326.33 kb, 465 downloads since 2016-01-14 

Re: Distinct

take a look!

Post's attachments

Attachment icon distinct_fixed.zip 326.56 kb, 506 downloads since 2016-01-14 

5 (edited by v_pozidis 2016-01-14 10:33:48)

Re: Distinct

The distinct works fine

but  there  is a problem. when you choose a name from  the combobox and write somethin in the textbox and save it,
you will see in the tablegrid that the saved record has only the value of the textbox and not the choosen one from the combobox.

Can you please see it ?

Re: Distinct

I see. Instead of viewing same names in combo you have to restrict double adding in combo. I think it would be more good.

Re: Distinct

the idea is that i have already a database full of values.
I will  include in the main software  a script excluding the same names from saving, but the problem will exist because the database is not new.

My question is choosing the names from the combobox it refuse to save the record.

Re: Distinct

take a look at this!

Post's attachments

Attachment icon distinct_fixed2.zip 326.7 kb, 619 downloads since 2016-01-14 

9 (edited by v_pozidis 2016-01-14 11:42:27)

Re: Distinct

no the script does't work.

Re: Distinct

send me again your project

11 (edited by v_pozidis 2016-01-14 11:56:20)

Re: Distinct

sent it

Post's attachments

Attachment icon distinct.zip 326.2 kb, 478 downloads since 2016-01-14 

Re: Distinct

I am afraid, I do not understand your problem, when I click on the combobox I get unique values even without the script!

Could you please explain what you try to achieve? Maybe a picture would help us.

13 (edited by v_pozidis 2016-01-14 12:17:04)

Re: Distinct

See the picture what i am asking

Post's attachments

Attachment icon questionINpic.jpg 37.01 kb, 297 downloads since 2016-01-14 

Re: Distinct

Which version of MVDB are you using? I am using 2.2 and the script is deactivated. Last entry has nothing linked on purpose.

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=1635

Post's attachments

Attachment icon distinct_test.png 19.07 kb, 300 downloads since 2016-01-14 

15 (edited by v_pozidis 2016-01-14 12:45:15)

Re: Distinct

2.3 beta.... because I am at work. and the version is portable

is there a way to find the version 2.2 cause home I have update it in the new version ?

Re: Distinct

Portable version? Where did you find it?

Re: Distinct

http://myvisualdatabase.com/download/se … 20beta.zip

it is the Beta version.

You can find it in the Forum section General and the first option

Sticky: Beta version 2.3.

Re: Distinct

ok  found the 2.2 version . The tablegrid works fine, but the script not

Re: Distinct

which script?

20 (edited by v_pozidis 2016-01-14 13:58:54)

Re: Distinct

http://myvisualdatabase.com/forum/misc. … download=1

This script doesn't work.  The script was from the member  pha1984

Re: Distinct

It works perfectly, you may have an issue with your setup!

I changed nothing in the script, just added the title to the columns in the grid to understand what was going on.

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&item=1637

Post's attachments

Attachment icon no_problemo.png 27.52 kb, 272 downloads since 2016-01-14 

Re: Distinct

Thank's maby the version 2.3 is not ready yet for use.
Could you send me the 2.2 version ?
I have update it in 2.3 and lost the previous version.

23 (edited by tcoton 2016-01-14 14:33:30)

Re: Distinct

I cannot attach it as the file is too large according to the forum's message:

Warning! The following errors must be corrected before your message can be posted:
•The selected file was too large to upload. The server didn't allow the upload.


I do not use 2.3 yet due to too many issues at the moment.

Anyway, thanks pha1984 for the script, it is much smaller than the one provided by Dmitry to check the duplicates!

Re: Distinct

thank's

25 (edited by v_pozidis 2016-01-14 16:03:53)

Re: Distinct

I have installed the 2.2
But the script   http://myvisualdatabase.com/forum/misc. … download=1   works only fro the first record.
After that it let you to add records with the same names