OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

how to add images to base, with and without using path
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
dbojan
General User
General User


Joined: 04 Apr 2007
Posts: 8

PostPosted: Thu Apr 05, 2007 4:20 am    Post subject: how to add images to base, with and without using path Reply with quote

1.Creating Database

START / ALL PROGRAMS / OPEN OFFICE.ORG / BASE
NEXT
FINISH
enter "mybase". Click on SAVE.




2. Creating Table in Database

in DATABASE colum on the left, click on TABLES
click on CREATE TABLE IN DESIGN VIEW, in TASKS panel

click under FIELD NAME. enter "code" without quotes.
FIELD TYPE should be "Text [VARCHAR]"

Right click on green arrow and select PRIMARY KEY.

Click below "code", enter "description"
set FIELD TYPE to "Text [VARCHAR]"
In the bottom set LENGTH to 150

Click below "description", enter "image"
set FIELD TYPE to "Image [LONGVARBINARY]"


Click on blue "SAVE" icon
Set TABLE NAME to equipment

FILE / CLOSE window.



3. Creating FORM

In "mybase - openoffice" window, click on FORMS in DATABASE colum.
click on USE WIZARD TO CREATE FORM in TASKS panel

click on ">>" button to add all fields to form
FINISH

CLOSE WINDOW.

4. Editing form

Right click on "equipment" form, in FORMS panel and select "EDIT"
(It is in the middle of the screen.)

Maximize window by double clicking on window title panel.
(If your window is zoomed in and you cannot zoom out, move mouse
over orange area, press and hold CTRL and rotate wheel on mouse)

Click on "TABLE control" (big gray area in the middle) and move
little green square on its middle-right. Move it little to the left.
So you have place for image container (it is called "IMAGE control")

In MENU select VIEW/TOOLBARS/FORM CONTROLS.

Click on third icon from the back on "FORM CONTROLS toolbar".
It is called "MORE CONTROLS"
on "MORE CONTROLS toolbar" click on third icon from the beginning.
It is called "IMAGE CONTROL"

Draw a square on the orange background, next to "TABLE FORM control".
By holding left mouse key. Create a square size of a few centimeters.


Double click on your newly created IMAGE control.
In DATA tab, under "DATA field ..." select "image"

(Optional: In GENERAL tab, set SCALE to NO)

Close "IMAGE control properties"

Click on save icon, close window.
Click on save icon in "mybase - openoffice" window

5. Input some data.
Double click on "equipment" form, in FORMS panel.
enter code: 111, description "blue image"

Doubleclick on image frame in the right part of the screen.
select some image from your disk.


below 111, enter 222, description "red image"

Doubleclick on image frame in the right part of the screen.
select some image from your disk.

Close that window, select YES to save table.






NEXT:
HOW to use path instead of putting images in database.


1. Edit form

Right click on "equipment" form, in FORMS panel and select "EDIT"
(It is in the middle of the screen.)

Double click on IMAGE control.
In DATA tab, under "DATA field ..." delete "image"
Close IMAGE control properties.

2. Create Macro
TOOLS/MACROS/ORGANIZE MACROS/OPEN OFFICE.ORG BASIC

In Macro name enter "ImageUpdate"
Click on NEW.

copy the following code:




dim oImageCtl as object
dim oFormCtl as object
dim sImagePath as String

oFormCtl = ThisComponent.Drawpage.Forms.getByName("MainForm")
oImageCtl = oFormCtl.getByName("ImageControl")
sImagePath = "C:\" + oFormCtl.getColumns.getByName("code").getString + ".jpg"
oImageCtl.ImageURL = ConvertToURL(sImagePath)





between "Sub ImageUpdate" and "End Sub"
Click on SAVE icon in "My Macros" window.
Close window.


3.
Back to Form editing.
Rightclick on "TABLE FORM control" (big gray area in the middle).
Select CONTROL.
In "TABLE CONTROL" PROPERTIES
Go TO EVENTS tab. Click on "..." next to "KEY RELEASED"
In ASSIGN ACTION window click on MACRO button.
In LIBRARY navigate to "MY MACROS/STANDARD/MODULE1" and select
"ImageUpdate" in the right window. Click OK.
Click OK again.
Close TABLE CONTROL properties.

Save FORM window, and close.


Rename images to 111.jpg and 222.jpg and put them in c:\ using windows explorer.

Double click on Equipment form. Navigate with keys.
There you go.



NOTES:

You can add Macro to "MOUSE INSIDE" event of TABLE Control
and "WHEN LOADING" event of the FORM.
To add event to FORM itself, right click on TABLE Control and select FORM.




To use path stored in database, add another column named "path" and in it enter
"c:\pics\" for example.

In macro change line
sImagePath = "C:\" + oFormCtl.getColumns.getByName("code").getString + ".jpg"
to
sImagePath = oFormCtl.getColumns.getByName("path").getString + oFormCtl.getColumns.getByName("code").getString + ".jpg"
And move images to c:\pics.




If you want to use environment variables, such as home path and home drive use:
sImagePath = Environ("HOMEDRIVE") + Environ("HOMEPATH") + "\" + oFormCtl.getColumns.getByName("code").getString + ".jpg"

Which should give "c:\Documents and Settings\<user name>"

To see environmet variables in Windows, click on start, run, enter "CMD", press enter.
Type set, press enter.


In Macros, all macros are contained on one page.

Some of the macro code is from other users posts.
Back to top
View user's profile Send private message Visit poster's website
joeryan
Newbie
Newbie


Joined: 03 Nov 2008
Posts: 1
Location: France

PostPosted: Mon Nov 03, 2008 7:56 am    Post subject: Thanks for the explanation Reply with quote

As a new user with a couple of existing Access databases, I've been looking around to find out how to integrate images. Your explantion solved my problem. It's a shame that such a roundabout route is required.
Back to top
View user's profile Send private message
Osopardo
Newbie
Newbie


Joined: 12 Nov 2008
Posts: 1
Location: México

PostPosted: Wed Nov 12, 2008 4:34 pm    Post subject: the macro don´t work Reply with quote

Hi, I follow step by step and when I want run the Macro it shows a dialog box

"Error en la ejecución de BASIC
A Exception have been made
Type com.sun.star.container.NoSuchElementExceptionMessage"

And it´s marked line number 5
oFormCtl = ThisComponent.Drawpage.Forms.getByName("MainForm")

Could you help me how to macro run?
I´m using OOo 3
SO: Windows Vista
languaje: Spanish
_________________
Thank you
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Wed Nov 12, 2008 5:43 pm    Post subject: Reply with quote

Hello

I think you have a wrong name for "mainform". Take care that the name in your macro and in your form is the same.

Go to this link for more information.
http://www.oooforum.org/forum/viewtopic.phtml?t=73329

I hope this helps you

Romke
Back to top
View user's profile Send private message
lmcneel
General User
General User


Joined: 10 Oct 2005
Posts: 5

PostPosted: Tue Dec 02, 2008 6:38 pm    Post subject: Link to Image Reply with quote

I have used the suggestions in this thread to solve a problem that I have had with a database of my artwork. I attached the macro to the "mouse inside" event so that the image is updated when you run the mouse over the image control. Is there a way to have the image updated immediately when the form changes to the next record?

Any help would be greatly appreciated.
_________________
Lance McNeel
www.mcneelart.com
Back to top
View user's profile Send private message Visit poster's website
keithclark1966
OOo Enthusiast
OOo Enthusiast


Joined: 18 Jan 2007
Posts: 189

PostPosted: Wed Dec 03, 2008 7:07 am    Post subject: Re: how to add images to base, with and without using path Reply with quote

This is just fantastic! Thank you very much for taking the time and writing this up for us.

I was looking for this very solution.

Keith
_________________
Open Office 3.0 under Ubuntu 9.04, XP and Vista
Back to top
View user's profile Send private message
keithclark1966
OOo Enthusiast
OOo Enthusiast


Joined: 18 Jan 2007
Posts: 189

PostPosted: Wed Dec 03, 2008 7:19 am    Post subject: Re: how to add images to base, with and without using path Reply with quote

dbojan wrote:
1.Creating Database

If you want to use environment variables, such as home path and home drive use:
sImagePath = Environ("HOMEDRIVE") + Environ("HOMEPATH") + "\" + oFormCtl.getColumns.getByName("code").getString + ".jpg"

Which should give "c:\Documents and Settings\<user name>"

To see environmet variables in Windows, click on start, run, enter "CMD", press enter.
Type set, press enter.


In Macros, all macros are contained on one page.

Some of the macro code is from other users posts.


What if the images are stored on a server somewhere on the web. Does http://location work?

Keith
_________________
Open Office 3.0 under Ubuntu 9.04, XP and Vista
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Wed Dec 03, 2008 11:31 am    Post subject: Reply with quote

Hello Lance McNeel
I think that the solution for you is written in the link.


Hello Keith

I did test it with your link and it seem to work. I can display the car with the link. The car you use in a shop

Romke
Back to top
View user's profile Send private message
lmcneel
General User
General User


Joined: 10 Oct 2005
Posts: 5

PostPosted: Fri Dec 05, 2008 4:28 am    Post subject: Image in Database Reply with quote

Thanks RPG!

I obviously didn't read far enough. It is working well now.
_________________
Lance McNeel
www.mcneelart.com
Back to top
View user's profile Send private message Visit poster's website
chriswatts
Newbie
Newbie


Joined: 14 Mar 2009
Posts: 1

PostPosted: Sat Mar 14, 2009 10:40 am    Post subject: Reply with quote

HI All,

i know its a long time ago but i would be interested in a solution for Images in Database
and the usage of Path in this special Way:

I would like to ingest an image from harddrive into a collum "Image" into the database (using the standart Image Control in a Form) and when the image "MyImage.jpg" is for example taken from the location "C:\Images" i would like to have an automatic feed of this path into a collum "Path" in the database as a normal STRING like "C:\Images\MyImage.jpg".

So everytime i am going to select a new image from the harddrive it will be written to the
database into "Image" and the path will go automatically to "Path".

Can anybody help me creating a Macro for this function? I am not really good at prgramming.

Thanks a lot

Cheers!

Chris
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Sun Mar 15, 2009 5:35 am    Post subject: Reply with quote

Base is not a database application. It is a set of drivers and configuration options to import data into office documents.
Additionally there are input-forms attachable to office documents so you can manually write some records back into the connected database, given that the connection provides for write-access.
All forms and reports embedded in a database-configuration are office documents.
You can create the same forms and reports outside the Base container as ordinary office documents.

On top of this (IMHO far over the top) there is some kind of "academic study" how one could use a free database server to serve a database from a temporary directory that comes piggyback with the configuration in the same zip-file (*.odb).
Yes, this caricature of a database can store images like the stand-alone original http://hsqldb.org can do, but if you actually do so, your memory may be blown away very soon. Have a look at this interesting thread: http://www.oooforum.org/forum/viewtopic.phtml?p=317188&highlight=#317188

Quote:
I would like to ingest an image from harddrive into a collum "Image" into the database (using the standart Image Control in a Form) and when the image "MyImage.jpg" is for example taken from the location "C:\Images" i would like to have an automatic feed of this path into a collum "Path" in the database as a normal STRING like "C:\Images\MyImage.jpg".

Then think about how you can add this feature to this "database" without being good in programming. I could do the job within an hour or so, but I would not recommend to do this in this "database application".
_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10106
Location: Germany

PostPosted: Mon Mar 16, 2009 2:32 am    Post subject: Reply with quote

http://development.openoffice.org/releases/3.1.m2_snapshot.html
Quote:
image controls: can be bound to text database columns, interpreting their content as relative link to the image i91310 feature-info:
Image controls in database forms can now be bound to text columns. Formerly, you could only bind them to columns whose content could reasonably be interpreted as binary (BLOB etc.). Now, when you select a text database column as source for the image control, then it will interpret the content of the respective column's content as URL, and load and display the image pointed to by this URL. Also, the URL might be relative to the document which the image control is embedded into.

_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
Back to top
View user's profile Send private message
amzg
General User
General User


Joined: 04 Jul 2009
Posts: 13

PostPosted: Sun Jul 05, 2009 8:30 am    Post subject: Any improvments/simplifications? Reply with quote

dbjojans original (and fantastic) post first in this thread is more than 2 years old and the last post above informs that version 3.1 now should handle this differently.

...but I just cannot find any information on how to actually do this now for 3.1?

I.e pictures stored in a separate folder and links/paths/urls etc in the forms.

I'm a beginner so please be easy on me Smile


Matias, Sweden
Back to top
View user's profile Send private message
RPG
Super User
Super User


Joined: 24 Apr 2008
Posts: 2697
Location: Apeldoorn, Netherland

PostPosted: Sun Jul 05, 2009 10:19 am    Post subject: Reply with quote

read the post complete
Back to top
View user's profile Send private message
amzg
General User
General User


Joined: 04 Jul 2009
Posts: 13

PostPosted: Sun Jul 05, 2009 2:15 pm    Post subject: Reply with quote

Thank you for your answer RPG! I have, however, both read and implemented the instructions in the first post and also read the other posts. Is there any particular post you refer to? My question is more if version 3.1 provides a more direct (easier?) way to do all this.

My sincerest thanks!

----

By the way, after fiddling around, I discovered I must change the suggested macro so it can handle multiple pictures per field. The following allows for 4 pics and, in the form, you can simply leave out any of them if you want fewer pics there;

dim oFormCtl as object
dim oImage1Ctl as object
dim oImage2Ctl as object
dim oImage3Ctl as object
dim oImage4Ctl as object
dim sImage1Path as String
dim sImage2Path as String
dim sImage3Path as String
dim sImage4Path as String

oFormCtl = ThisComponent.Drawpage.Forms.getByName("MainForm")
oImage1Ctl = oFormCtl.getByName("ImageControl")
oImage2Ctl = oFormCtl.getByName("ImageControl1")
oImage3Ctl = oFormCtl.getByName("ImageControl2")
oImage4Ctl = oFormCtl.getByName("ImageControl3")
sImage1Path = oFormCtl.getColumns.getByName("path").getString + oFormCtl.getColumns.getByName("bild1").getString + ".jpg"
sImage2Path = oFormCtl.getColumns.getByName("path").getString + oFormCtl.getColumns.getByName("bild2").getString + ".jpg"
sImage3Path = oFormCtl.getColumns.getByName("path").getString + oFormCtl.getColumns.getByName("bild3").getString + ".jpg"
sImage4Path = oFormCtl.getColumns.getByName("path").getString + oFormCtl.getColumns.getByName("bild4").getString + ".jpg"
oImage1Ctl.ImageURL = ConvertToURL(sImage1Path)
oImage2Ctl.ImageURL = ConvertToURL(sImage2Path)
oImage3Ctl.ImageURL = ConvertToURL(sImage3Path)
oImage4Ctl.ImageURL = ConvertToURL(sImage4Path)

bild1, bild2 etc refers to the column1, column2 etc in the form where you provide the name of the pics.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group