[Solved] Populating database records into column per record

Discuss the database features
Post Reply
MINTHETNAUNG
Posts: 18
Joined: Mon Jun 18, 2018 3:33 am

[Solved] Populating database records into column per record

Post by MINTHETNAUNG »

I am trying to populate the record, which I stored them into database (base), then, according to the number of row records in Database table, I want them to be populated into the different number of columns i.e. if there are 3 rows of data records, I want them to populate into B1:10, C1:C10, D1:D10. Hope you get what I am trying to do. The idea is there. So, is there a way to do it with Calc Macro?
Last edited by MINTHETNAUNG on Fri Jun 22, 2018 11:36 am, edited 1 time in total.
Openoffice 4.1.5 on Windows 10
UnklDonald418
Volunteer
Posts: 1540
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Populating database records into columns as per record

Post by UnklDonald418 »

Writing a macro for this might be possible, but it probably wouldn't be easy,
First you should explore other options.
One possibility would be a pivot table. See the Calc Guide Chapter 8 – Using the Data Pilot found at
https://wiki.openoffice.org/wiki/Docume ... e_Chapters
Another possibility would be to use a database query to pivot the data and then use the results of the query as a data source for the spreadsheet.
Or probably the best option would be to use the power of a database and don't use a spreadsheet as a crutch.
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
User avatar
MrProgrammer
Moderator
Posts: 4883
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Populating database records into columns as per record

Post by MrProgrammer »

MINTHETNAUNG wrote:if there are 3 rows of data records, I want them to populate into B1:10, C1:C10, D1:D10. Hope you get what I am trying to do.
Perhaps you need to read about TRANSPOSE function in Calc. No, I do not understand what you would like to do. B1:B10, C1:C10, D1:D10 is thirty cells. If you have three database records, what is the source of the thirty pieces of data?

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
MINTHETNAUNG
Posts: 18
Joined: Mon Jun 18, 2018 3:33 am

Re: Populating database records into columns as per record

Post by MINTHETNAUNG »

Thank you for the answers. But I don't think it works for what I want. To make it clear, here is what I want it to be done. (See Attached Photo - test1) It is a sample of Base Database table. I want it to be in such a way that if the items have a certain company (depends on what user chooses i.e. FruitAmerica Pte Ltd for e.g.), I want them to be put into a different number of columns depending on how many items that company has offered. (See Attached Photo - test2). So, is it possible to do with Calc macro?
Attachments
Required Result Sample Photo (test2)
Required Result Sample Photo (test2)
test2.PNG (5.41 KiB) Viewed 2121 times
Database Sample Photo (test1)
Database Sample Photo (test1)
test1.PNG (7.84 KiB) Viewed 2121 times
Openoffice 4.1.5 on Windows 10
MINTHETNAUNG
Posts: 18
Joined: Mon Jun 18, 2018 3:33 am

Re: Populating database records into columns as per record

Post by MINTHETNAUNG »

I was able to do it with some work-around. Thank you all! ^ ^
Openoffice 4.1.5 on Windows 10
Post Reply