Topic: What is the simplest way to copy a record in a table without coding
Hi everyone
I have a problem, perhaps stupid, but ?
My attempt attached.
Iif anyone has a solution ?
My Visual Database → General → What is the simplest way to copy a record in a table without coding
Hi everyone
I have a problem, perhaps stupid, but ?
My attempt attached.
Iif anyone has a solution ?
You forgot the attachment.
sorry. file to large for upload
Hi,
Yes, it is possible (sort of!) without any code.
Have a look at the attachment.
TO CREATE a record
1. click on the 'create' button
2. enter your details
3. click 'copy/save' to save your new record
4. close the form.
To EDIT a record
1. double-click on the row in the tablegrid you want to edit
2. make any changes and click 'copysave' to save your changes
3. close the form
To COPY a record
1. double-click on the row in the tablegrid you want to edit
2. click 'copy/save' first (this prevents the selected row from being overwritten
3. make any changes (if creating a copy BASED on the selected row) and / or just click 'copy/save' to create your new record.
It sounds a bit complicated but just try it out in the attachment and it should be straightforward.
Just be careful when doing this as it is very easy to create duplicate records unintentionally.
Regards,
Derek.
thanks Derek
Now I see that I should have just unchecked "Close the current form after saving". The only thing you need to recognize is the "New record" mode, and after that close the form manually.
Universal Copy
To copy a record you need very little code
function DB_CopyRecord( ATableName: string; AID: integer ):integer;
// universal function for copying a record
begin
// create a temporary table with a structure identical to the copied record
SQLExecute('CREATE TEMPORARY TABLE tmp AS SELECT * FROM ['+ATableName+'] WHERE id = '+IntToStr(AID));
// reset the value of the ID field
SQLExecute('UPDATE tmp SET id = NULL');
// insert record back
SQLExecute('INSERT INTO ['+ATableName+'] SELECT * FROM tmp');
// get the ID of the new entry
Result := Last_Insert_ID();
// delete temporary table
SQLExecute('DROP TABLE tmp');
end;
https://k245.ru/en/mvdb-en/universal-copy.html
My Visual Database → General → What is the simplest way to copy a record in a table without coding
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi