Topic: avoid repeated data

hi

I have a form with three textboxes
can these textboxes be related to each other  in order to avoid saving repeated data.

for example :
suppose that I fill textbox1 with the number 13 and textbox2 is filled with 14 and in textbox3 I write 15

what I want to know is that whether there is a scrip that when I write 13 - 14 and 15 in these textboxes an error massage comes up and avoid the repeated data to be saved?

thank you

Re: avoid repeated data

yes, attach your project here

3 (edited by identity 2016-01-19 15:59:13)

Re: avoid repeated data

the attached project is not my real project but it is similar to my project

if you run the project you'll see that when you search in the form1, there are two collumns in the tablegrid that are exactly the same.

what i like to do is that:

when i insert 3 figures in the edit1 and edit2 and edit3 buttons, if all of the three figures are the same as previous entry, an alert message says that "you have recorded these numbers before"

thank you

Post's attachments

Attachment icon Linked Lists.rar 280.37 kb, 492 downloads since 2016-01-19 

Re: avoid repeated data

Added a duplicate check in your project.

Post's attachments

Attachment icon Linked Lists_fixed.zip 7.26 kb, 477 downloads since 2016-01-19 

Dmitry.

Re: avoid repeated data

thanks for your reply
But I have an older version of this program and I cant open your project.

I wonder whether the script you have written is supported in the earlier versions for example v.1.40?

would it be possible for you to give me an script which is supported in my version of this program?

thank you

Re: avoid repeated data

Please download latest freeware version here (1.45)
https://www.dropbox.com/s/t6iudxgkz9wct … 5.exe?dl=0


Your project for version 1.45:

Post's attachments

Attachment icon Linked Lists_fixed2.zip 3.67 kb, 487 downloads since 2016-01-19 

Dmitry.

Re: avoid repeated data

thank you so much

there is still two minor problems

first my project is a little heavier than this project. there are seven textboxes in my project

and second problem which is more important is that:

when I fill all the three textboxes with similar numbers the error message is shown but all the textboxes may not be necessarily filled
sometimes just two of the textboxes are filled with number and in my case sometimes only five out of seven textboxes have numbers in them

thanks

8 (edited by identity 2016-01-20 06:00:24)

Re: avoid repeated data

hi
I have found a solution to my first problem which was about seven similar textboxes but the second problem still exist
could you please help me with that

in the script you wrote (duplicate check) it works fine when you enter all of the text boxes unfortunately if for example one of the textboxes is left blank then your script does not show the alert and it saves the entry anyway.

suppose that I have seven textboxes and only some of them should be filled with figures so what I want to do is that :
for example In one entry I fill the text boxes like this:
edit1= 100
edit2= 200
edit3= 300
edit4 and5 and 6 and 7= blank
then I save the first entry
when I open the second entry and fill the edit tabs like my first entry, I want the project to show an alert that says "you have recorded these numbers before"
sometimes I need to fill all of the seven textboxes with numbers and sometimes only 3 or 4 of them should be filled and others should be left blank. Is it possible?

I also want to define a button that checks if the numbers are repeated or not
for example if they are repeated the script says  "you have recorded these numbers before"
and if the numbers are new the script says that "you did not record these numbers before"
what is the scrip for this button?

thank you so much

Re: avoid repeated data

identity
In the latest version script works exactly as you need, but in the old version not available some features, so need a little more script:

procedure frmAddtext_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    sFields, sValues: string;
    s1, s2, s3: string;
begin
    sFields := 'editone;edittwo;editthree';
    s1 := '"'+frmAddtext.Edit1.Text+'"';
    s2 := '"'+frmAddtext.Edit2.Text+'"';
    s3 := '"'+frmAddtext.Edit3.Text+'"';

    if s1='""' then s1 := 'NULL';
    if s2='""' then s2 := 'NULL';
    if s3='""' then s3 := 'NULL';

    sValues := s1+';'+s2+';'+s3;


   if CheckDublicate(frmAddtext.dbAction, '"Table"', sFields, sValues, frmAddtext.Button1.dbGeneralTableId) then
   begin
        ShowMessage('You have recorded these numbers before.');
        Cancel := True;
   end;
end;
Dmitry.