Topic: DUPLICATE RECORD

Hello MVD?

I want to duplicate a line of record in tablegrid by just clicking a button.  I need a help on this codes  please...

Thanks in advance !

Re: DUPLICATE RECORD

procedure Form1_btnDup_OnClick (Sender: TObject; var Cancel: boolean);
begin
    SqlExecute('INSERT INTO Table1 (Field1, Field2, Field3, Field4, Field5) '
      + 'SELECT Field1, Field2, Field3, Field4, Field5 FROM Table1'
      + 'WHERE id = ' + Form1.TableGrid1.sqlValue);
    Form1.TableGrid1.dbUpdate;
end;

3 (edited by manixs2013 2019-05-01 03:50:59)

Re: DUPLICATE RECORD

Thanks ehWagner!

My database main tables has a connections to other tables...

Re: DUPLICATE RECORD

manixs2013 wrote:

Thanks ehWagner!

My database main tables has a connections to other tables...

Just specify in the SQL query all fields, including foreign keys.

Dmitry.

Re: DUPLICATE RECORD

Hi Manix,
Another way of doing it is to copy all the values from the selected tablegrid row onto a form.
You don't have to re-type all the details but it also gives you the option to change some of the copied details before saving the record (I'm not sure why you might intentionally want to create duplicates).
Derek.

Post's attachments

Attachment icon copyrow.zip 337.51 kb, 353 downloads since 2019-05-01 

Re: DUPLICATE RECORD

WOW WOW WEEEEEE

THANKS TO ALL!

Re: DUPLICATE RECORD

Beware of data duplicates, it is the nightmare of database managers!! If you create data duplicates then, you do not understand the purpose of a database. On the long haul you WILL have issues, guaranteed! It is better to query properly than duplicating over and over like you would do with excel spreadshits (pun intended).

The purpose of a database is to store unique data and then query them to display them the way you want. You can have one set of data and display this data in multiple ways: in multiple grids with different filters, in a text summary, in a diagram, etc... Remember: ONE data, multiple ways to display, like one theater screen with multiple viewers looking the very same film but feeling different ways. smile

Re: DUPLICATE RECORD

YES!

SIR TCOTON, May real purpose to duplicate a line of a record because i have instance that the records has almost the same information only in the amount has a distinction.  Sometime this is 10 lines of records... I dont want to type and type it again...

I need a help to solve this problem from the MVD Wizards!

Thanks!

Re: DUPLICATE RECORD

derek wrote:

Hi Manix,
Another way of doing it is to copy all the values from the selected tablegrid row onto a form.
You don't have to re-type all the details but it also gives you the option to change some of the copied details before saving the record (I'm not sure why you might intentionally want to create duplicates).
Derek.


Sir Derek!

Help me to include the connected table please..
attached is the sample

Thanks!

Post's attachments

Attachment icon copyrow.zip 337.79 kb, 299 downloads since 2019-05-02 

Re: DUPLICATE RECORD

manixs2013,
I went ahead and corrected it for you.

Post's attachments

Attachment icon copyrow_Fixed.zip 582.25 kb, 379 downloads since 2019-05-02 

Re: DUPLICATE RECORD

YESSSSSSSSSSS

Thanks to : DriveSoft, Tcoton, Derek and ehwagner..


KUDOS to ALL!

Re: DUPLICATE RECORD

After seeing your sample, it seems that there was a misunderstanding with the vocabulary, I thought you were looking to duplicate data within the database at first glance and my brain froze on the keyword "duplicate". Please include your project or a screenshot with your question next time. wink