Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy records from one block to another

Status
Not open for further replies.

misterimran

Programmer
May 13, 2002
19
0
0
PK
Hi Guys,
I have two blocks on my form- Block1 and Block2. Both blocks have same fields but different tables are associated. When I execute query it brings record in both of the blocks. Now I want to copy all records in block 1 to block 2 how can I do this? Like I want to clear block 1 and copy all it records to block2 and then save block2.
Pliz help.

Best regards,
Imran Baig
 
How about a button that uses GET_BLOCK_PROPERTY(...,LAST_QUERY) to determine the WHERE clause used on each block. Use those clauses to delete from the table in block 2, then insert into that table selecting from the first blocks table using block 1's where clause.
 
Hello again,

actually i have include a check box field in the Block2 and user can check and uncheck againts each record. I only want to transfer the records into block 1 whose check box is checked. Thats why i have to pick some records not all records. So where_clause wont work.

I just need to copy the records in block2 to block1.

Pliz help again.
Imran
 
Then you need to copy each record one by one. Code to do this might look something like this

[tt]Go_Block('block2');
Clear_Block(NO_VALIDATE);
Go_Block('block1');
First_Record;

LOOP
EXIT WHEN :block1.rowid IS NULL;

IF :block1.checkbox = 'Y'
THEN
:block2.item1 := :block1.item1;
:block2.item2 := :block1.item2;
.
.
Go_Block('block2');
Down;
Go_Block('block1');
END IF;

EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
Down;
END LOOP;

Go_Block('block2');
First_Record;[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top