By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,264 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,264 IT Pros & Developers. It's quick & easy.

Linking images in MS Access

P: 6
Hello,

I'm having trouble with MS Access 2007 (running Vista). I have a table with multiple fields, including several text fields containing the links to images relevant to that record. The outcome is a form with multiple images that change with each record.

This works fine, however once I shut the database down and restart, it stops working. I've figured out that it is because i'm only putting in the relative path (image.jpg) rather than the absolute path (c:\temp\image.jpg). The database and images are stored in the same folder. So in the course of shutting down and reopening the database, the images forget where to look for themselves.

Putting the absolute path solves the problem... however I want to eventually put this database on a CD, so putting these absolute paths wouldn't work would it (no longer running off the c drive)?

So, is there a way to make the database recognise it's position and therefore recognise relative file paths? Or another way around this?

Thanks so much
G

An aside... I'm not using attachments, as I want to be able to convert this database to older versions for others to view (however I've only got 2007 to work with).

I can't embed OLE objects since I keep getting a "OLE server may not be registered' error. But from my understanding I'm better off not using this function (I've got >200 images). So I haven't really tried fixing this.

I don't know a lot about codes etc.
Aug 7 '08 #1
Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,494
CurrentDB.Name has the full path of where the database was opened from.

From this you can extract the folder that the images are relative to.

Does that help?
Aug 7 '08 #2

P: 6
Yes I think so. I also have come across Application.CurrentProject.Path.

Where do I put this so that it points all the images to the correct path?

Thanks for you help.
Aug 8 '08 #3

P: 6
OK, I had an idea from something I I saw on another website...

I made a module that says:

-----
Option Compare Database

strFolderName = Application.CurrentProject.Path
-----

I then put text box [txtPath] on the form with the Control Source being

= [Application].[CurrentProject].[Path]

I then have my original text box [Image1] with the image sub folder and file name stored in it.

In the Image control source I've put:

=[txtPath]&[Image1]

This seems to work, however I know I've probable gone round in circles and there must be a neater way of doing it. Next step is to try moving the database.

Also, regarding the above module, do I need to add anything further than this? I don't know anything about modules, but this one just seems to short or something.

Thanks
Gem
Aug 8 '08 #4

P: 6
I did find a shorter way:

By just putting

=[Application].[CurrentProject].[Path]&[Image1]

in the image control source. Seems to eliminate the need for the module.

It seems to work now, are there any major problems that using this method may cause to my database?

What is the difference between this and CurrentDb.Name?
Aug 8 '08 #5

NeoPa
Expert Mod 15k+
P: 31,494
I did find a shorter way:

By just putting

=[Application].[CurrentProject].[Path]&[Image1]

in the image control source. Seems to eliminate the need for the module.

It seems to work now, are there any major problems that using this method may cause to my database?
...
This is the neater way of doing it. Doing dynamically (rather than with a module) seems a much better idea.

I never discovered that property of that object before, so I always stripped it from CurrentDB.Name.
...
What is the difference between this and CurrentDb.Name?
Your method is just better :->

I expect I'll be using that from now onwards.
Aug 8 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.