Adding photos to Base

Discuss the database features
Post Reply
Gilkar1944
Posts: 2
Joined: Fri Mar 15, 2019 11:42 pm

Adding photos to Base

Post by Gilkar1944 »

I read about adding images to Base but the thread was from 2012. I must confess it was beyond my expertise.
Fast Forward to 2019
I have created a table and form in Base. It is a very simple form and the data I need to record is very basic.
I just need last name, first name, and email address (email is the primary key). In addition I need to add a photo to the base for each record (I am a photographer). My workflow is: Have a client fill out the form, photograph the client, add one photo to the record, move on to next client. I do this because I am sending each client a copy of his photo via e-mail at a later time. In the past we have done this with paper and pencil but people have terrible handwriting (in general), so the thought of having the client fill out his own database form form is very appealing. In my version of Open Office (4.1.6) there is a field option called "photo". Sure enough I designed the form with that field and I can access my hard drive where the photo files are stored (as .jpegs), and add the photo to the base. However, I get error messages when i try to save the records and the database does not save. Can anyone give me any advice? I am not a power user and i'd be hard pressed to write macros but I can follow step by step instructions. For example, do this, then do that. Thanks in advance.
Open Office 4.1.6
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Adding photos to Base

Post by Villeroy »

OpenOffice did not change since 2013, Base did not change since 2011. Pictures in forms are the same issue since 2005. There are hundreds of ready made photo applications which do a better job than a self made tool based on some office suite. Nevertheless, mapping database records to picture files (not stored within the database) is fairly easy. And if you install the report builder extension, you can get some nice report layouts with pictures included. May be you want to install https://libreoffice.org which is under active development and includes the report builder.
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: 1544
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Adding photos to Base

Post by UnklDonald418 »

I can follow step by step instructions.
First, create a directory to hold your database, and move the odb file into that directory.
Create a sub-directory to hold your pictures and add them now so they are available when we need them a little later..
Now to your database table add a field of VarChar type. Give it a length of at least 100 characters because it will hold the path and filename of the picture associated with each record.
Still in the database, right click on your form document and select Edit to open the form document in Design Mode.
The Form Controls toolbar should appear along the left margin of the form. (If not select View>Toolbars>Form Controls to toggle it on).
Select the button third from the bottom on the toolbar labeled More Controls to toggle a floating controls toolbar.
Select the button labeled Image Control ( second row right column).
The mouse cursor should change to cross hairs. Use click and drag to draw a box on the form to display the image.
Right click inside the image box and select Control from the menu to open the Properties: Image Control dialog.
On the General tab of the dialog you can fine tune the size and position of the of the image and change the Border color and Border type.
On the Data tab of the dialog is a Data field list, select the field name you added to your table.
Close the floating toolbar.
Select Design Mode On/Off button near the top of the Forms Controls toolbar.
The form will now be in the live mode and should display the data from the first record in your database.
Press <Ctrl>S to save the changes to your form.
Right click inside the box surrounding the image control and select Insert graphics from to open a file picker dialog.
Navigate to and select the picture you want associated with the record
Select Open on the dialog to insert the picture onto your form.
Move to another database record and using the above process insert a picture there also.
Move back the the first record to verify it still shows the correct picture.

The Embedded Base database connection (lower left corner of the main database window) is a handy format for learning about databases. An odb file is actually a zip archive containing all the Tables, Queries, Forms and Reports as well as an old version the the HSQL database engine.
On occasion something can go awry during the zip process and the odb file becomes corrupt. That often results in all the data being lost! So making a back up after each session where changes have been made is highly recommended.

A solution to the problem is to convert your database to a JDBC connection, also referred to as a Split database where the tables are stored outside of the odb file. One issue when using the JDBC connection is that the table design GUI will no longer allow editing of existing fields. There are a couple of ways around that but be aware of that issue.
Once your Embedded database is working they way you want, download the wizard from
[Wizard] Create a new 'split' HSQL 2.x database
Place a copy of the wizard in your database directory.
Run the wizard and follow the few steps to create a JDBC connection.
The wizard uses a macro to create two sub-directories, it puts the tables into the database directory and a newer version of the HSQL database engine in the driver directory.
The macro runs each time you open the database so if you get a macro warning message you can avoid it in the future by going to Tools>Options>OpenOffice>Security>Macro Security and set the Security Level to Medium. Then on the Trusted Sources tab add you database directory to the Trusted file locations list.
With the JDBC connection still open, open your Embedded database also.
Using Cut and Paste or drag and drop copy your table(s) from the Embedded database to the JDBC database.
When copying tables you will get a Copy Table dialog.
Be sure to select the Definition and data option and then select Create.
Also copy any queries, forms and reports to the JDBC database.
If everything goes as planned, test to make sure all the queries, forms and reports work.
Exit both databases.
If you like, you can removed the Embedded database, or keep it for later reference if you like.
Rename the wizard odb file to something more meaningful and you should be good to go.
You should still perform regular backups, but they don't need to be as often as with an Embedded database. Just remember you must back up not only the odb file but also the sub-directories.
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
Gilkar1944
Posts: 2
Joined: Fri Mar 15, 2019 11:42 pm

Re: Adding photos to Base

Post by Gilkar1944 »

Thank you for the instructions I will try this
Open Office 4.1.6
Post Reply