| View previous topic :: View next topic |
| Author |
Message |
dbojan General User

Joined: 04 Apr 2007 Posts: 8
|
Posted: Thu Apr 05, 2007 4:20 am Post subject: how to add images to base, with and without using path |
|
|
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 |
|
 |
joeryan Newbie

Joined: 03 Nov 2008 Posts: 1 Location: France
|
Posted: Mon Nov 03, 2008 7:56 am Post subject: Thanks for the explanation |
|
|
| 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 |
|
 |
Osopardo Newbie

Joined: 12 Nov 2008 Posts: 1 Location: México
|
Posted: Wed Nov 12, 2008 4:34 pm Post subject: the macro don´t work |
|
|
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 |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Wed Nov 12, 2008 5:43 pm Post subject: |
|
|
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 |
|
 |
lmcneel General User

Joined: 10 Oct 2005 Posts: 5
|
Posted: Tue Dec 02, 2008 6:38 pm Post subject: Link to Image |
|
|
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 |
|
 |
keithclark1966 OOo Enthusiast

Joined: 18 Jan 2007 Posts: 189
|
Posted: Wed Dec 03, 2008 7:07 am Post subject: Re: how to add images to base, with and without using path |
|
|
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 |
|
 |
keithclark1966 OOo Enthusiast

Joined: 18 Jan 2007 Posts: 189
|
Posted: Wed Dec 03, 2008 7:19 am Post subject: Re: how to add images to base, with and without using path |
|
|
| 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 |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Wed Dec 03, 2008 11:31 am Post subject: |
|
|
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 |
|
 |
lmcneel General User

Joined: 10 Oct 2005 Posts: 5
|
Posted: Fri Dec 05, 2008 4:28 am Post subject: Image in Database |
|
|
Thanks RPG!
I obviously didn't read far enough. It is working well now. _________________ Lance McNeel
www.mcneelart.com |
|
| Back to top |
|
 |
chriswatts Newbie

Joined: 14 Mar 2009 Posts: 1
|
Posted: Sat Mar 14, 2009 10:40 am Post subject: |
|
|
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 |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Sun Mar 15, 2009 5:35 am Post subject: |
|
|
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 http://forum.openoffice.org |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Mon Mar 16, 2009 2:32 am Post subject: |
|
|
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 http://forum.openoffice.org |
|
| Back to top |
|
 |
amzg General User

Joined: 04 Jul 2009 Posts: 13
|
Posted: Sun Jul 05, 2009 8:30 am Post subject: Any improvments/simplifications? |
|
|
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
Matias, Sweden |
|
| Back to top |
|
 |
RPG Super User

Joined: 24 Apr 2008 Posts: 2696 Location: Apeldoorn, Netherland
|
Posted: Sun Jul 05, 2009 10:19 am Post subject: |
|
|
| read the post complete |
|
| Back to top |
|
 |
amzg General User

Joined: 04 Jul 2009 Posts: 13
|
Posted: Sun Jul 05, 2009 2:15 pm Post subject: |
|
|
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 |
|
 |
|