[Solved] Copy value from preceding row in grid subform

Creating and using forms
Locked
calvin123
Posts: 4
Joined: Thu Aug 07, 2025 2:36 pm

[Solved] Copy value from preceding row in grid subform

Post by calvin123 »

Dear all,

I am on Windows 11 with the most recent version of OpenOffice.

In my Base database I do have a customer form which also has a grid/table subform listing items these customers bought.
Now when I create a new item I want to be able to copy the value of the preceding row (and of course column) into the current cell.

So if I have this setup (sorry for the Ascii-Art but the BCode tables don't work):

Customer ABC

Items
ID   | Name   | Description  | Price
1    | Tomato | Red and big  | 2,99
2    | Apple  | ...          | ...

Now when I am in the "Description column of the "Apple" I want to press "F2" and the macro should copy the value of the description of the preceding item "Red and Big" from the "tomato" into the description column of the current item.
And if the cursor would be in the "Price" column, it would copy the "2,99" from the preceding line.
Can you help me? :?:
Last edited by robleyd on Sat Aug 09, 2025 12:21 am, edited 3 times in total.
Reason: Add green tick
OpenOffice 4.1.15 on Windows 11
User avatar
Villeroy
Volunteer
Posts: 31349
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Copy value from preceding row in grid subform

Post by Villeroy »

No macro needed.
Attachments
aooforum112997.odb
Subform inheriting default values from parent form
(12.84 KiB) Downloaded 11 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
UnklDonald418
Volunteer
Posts: 1573
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Copy value from preceding row in grid subform

Post by UnklDonald418 »

Or if you want to try a macro
Base Copy Field or Clone Record - Example
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
calvin123
Posts: 4
Joined: Thu Aug 07, 2025 2:36 pm

Re: Copy value from preceding row in grid subform

Post by calvin123 »

Thank you both! I will test this later and will give a feedback.
OpenOffice 4.1.15 on Windows 11
calvin123
Posts: 4
Joined: Thu Aug 07, 2025 2:36 pm

Re: Copy value from preceding row in grid subform

Post by calvin123 »

Hi, it works now.
I looked at both solutions and in the end I went with the macro.

Thank you again and have a nice weekend!
cal
OpenOffice 4.1.15 on Windows 11
Locked