Page 1 of 1

Macro to Autoload Image URL per Field Text?

Posted: Tue Jun 09, 2009 7:02 pm
by sdritchey
Hello all,

I'm looking to write a macro to autoload an image into a field based on the text in another field. To be more specific:

I have a plant ID database with scientific name, and a bunch of other information. I also have a folder with several images of each plant. The image files are named by the scientific name 1, scientific name 2, scientific name 3, etc. When I load the record I want the image fields to automatically look for the image file in a specified folder using the scientific name field as the first part of the file path, and then adding a 1, 2, or 3...

Could anyone break this macro down for a beginner like myself?

Or is it possible to do this by placing a URL path in the "default value" that somehow references the scientific name field and skip the macro?

Thanks,
Steve

Re: Macro to Autoload Image URL per Field Text?

Posted: Tue Jun 09, 2009 10:08 pm
by TheGurkha
Does this help: how to add images to base, with and without using path.

If this has answered your question please go to your first post and use the Edit button, and add [Solved] to the start of the title. You can use the green tick icon at the same time if you like.

Re: Macro to Autoload Image URL per Field Text?

Posted: Tue Jun 09, 2009 11:31 pm
by sdritchey
Hi Gurkha,

I was looking at that before I posted, but there's 2 things. Those macros were written before the 3.1 update, and now with 3.1 I can have a text field that stores the path and retrieves the images without the macro (scroll down to the bottom of the thread). I've got that up and running no problem. The other thing missing from that macro is the part that retrieves the text from the "scientific name" field and pastes that into the file path.

Thanks for the help,
Steve

Re: Macro to Autoload Image URL per Field Text?

Posted: Tue Jun 09, 2009 11:37 pm
by TheGurkha
I'm afraid I can't help further. Hopefully someone more experienced in this will come through this thread soon.

Re: Macro to Autoload Image URL per Field Text?

Posted: Sun Jun 21, 2009 10:32 am
by Villeroy
http://development.openoffice.org/releases/3.1.0.html
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.
Seemingly, the developers did not change the way how binary data (such as pictures) are handled. They just modified the image control to accept a text field. The text field is supposed to contain URLs as a pointer to picture files outside the database, relative to the Base document's path.
pics/holyday/beach.png
pics/dog/shit.bmp
pics/cat/scratch.jpg

Re: Macro to Autoload Image URL per Field Text?

Posted: Sun Jun 21, 2009 12:26 pm
by RPG
hello
I was looking at that before I posted, but there's 2 things. Those macros were written before the 3.1 update, and now with 3.1 I can have a text field that stores the path and retrieves the images without the macro (scroll down to the bottom of the thread). I've got that up and running no problem. The other thing missing from that macro is the part that retrieves the text from the "scientific name" field and pastes that into the file path.
You have only to point the data field from your image control to the field of your table which kept the name of the file. I knew people love macros but i"m afraid you can not use them in this case.

This all if I understand you correct.
Romke