Pictures/Images in Tables

J

John W. Vinson

Thanks John

I have made the changes you have suggested.

I have a table (TableImagePath) containing just G:\VinylImages\

and in the other table (VinylTable) i have rows including the text row
called 'Picture' that contains the image name e.g., Vinyl1.jpg

If i put G:\VinylImages\Vinyl1.jpg in the VinylTable and make a form and set
an Image control to 'Picture' the jpg shows up (brilliant!).

When i concatenate TableImagePath and Picture and get the expression to show
G:\VinylImages\Vinyl1.jpg. However this does not show any jpg?

Could you please try and help me find out where i am going wrong.

Thanks

Sure. Please post your code; it's a bit hard to tell where you're going wrong
when you don't tell us where you're going!
 
A

adrian007uk

Besides what i have explained above I used a query to combine 'Image Path'
with 'Picture'.

I used Expr1: [Image Path] & "" & [Picture]

This created G:\Vinyl Image\Vinyl1.jpg
G:\Vinyl Image\Vinyl2.jpg
G:\Vinyl Image\Vinyl1.jpg

ETC

When i try and point the image control to this query i get nothing!

When i type the full file path in the text box of the 'Picture' row in the
'Vinyl Table' and set the image control to 'Picture' the image is there.
 
J

John W. Vinson

Besides what i have explained above I used a query to combine 'Image Path'
with 'Picture'.

I used Expr1: [Image Path] & "" & [Picture]

This created G:\Vinyl Image\Vinyl1.jpg
G:\Vinyl Image\Vinyl2.jpg
G:\Vinyl Image\Vinyl1.jpg

ETC

When i try and point the image control to this query i get nothing!

When i type the full file path in the text box of the 'Picture' row in the
'Vinyl Table' and set the image control to 'Picture' the image is there.

I would suggest using code in the form's Current event to push the filename
into the image control:

Private Sub Form_Current()
If Not IsNull(Me![Picture]) Then
Me![Imagecontrol].Picture = Me![Image Path] & Me![Picture]
End If
End Sub

This assumes that either Image Path ends with a \ delimiter, or Picture starts
with one - otherwise you'll need to concatenate that in as well.
 
A

adrian007uk

Hi John

I have tried your code but the database does not like the line:

Me![Imagecontrol].Picture = Me![Image Path] & Me![Picture]

It is the 'Image Path' that access apparently can't find!

I have checked the spelling and made sure the expression matches exactly so
i cannot work out why the code will not run.

Adrian

John W. Vinson said:
Besides what i have explained above I used a query to combine 'Image Path'
with 'Picture'.

I used Expr1: [Image Path] & "" & [Picture]

This created G:\Vinyl Image\Vinyl1.jpg
G:\Vinyl Image\Vinyl2.jpg
G:\Vinyl Image\Vinyl1.jpg

ETC

When i try and point the image control to this query i get nothing!

When i type the full file path in the text box of the 'Picture' row in the
'Vinyl Table' and set the image control to 'Picture' the image is there.

I would suggest using code in the form's Current event to push the filename
into the image control:

Private Sub Form_Current()
If Not IsNull(Me![Picture]) Then
Me![Imagecontrol].Picture = Me![Image Path] & Me![Picture]
End If
End Sub

This assumes that either Image Path ends with a \ delimiter, or Picture starts
with one - otherwise you'll need to concatenate that in as well.
 
J

John W. Vinson

Hi John

I have tried your code but the database does not like the line:

Me![Imagecontrol].Picture = Me![Image Path] & Me![Picture]

It is the 'Image Path' that access apparently can't find!

I have checked the spelling and made sure the expression matches exactly so
i cannot work out why the code will not run.

Assuming that your path table is named tblImagePaths and that the field is
named [Image Path] then you could just leave tblImagePaths out of the form's
recordsource entirely, and look it up as needed:

Me![Imagecontrol].Picture = DLookUp("[Image Path]", "tblImagePaths") &
Me![Picture]
 
A

adrian007uk

Sorry John,

It's still not working. Do i need to put this new code as an 'OnCurrent'
event or somewhere else?

Adrian

John W. Vinson said:
Hi John

I have tried your code but the database does not like the line:

Me![Imagecontrol].Picture = Me![Image Path] & Me![Picture]

It is the 'Image Path' that access apparently can't find!

I have checked the spelling and made sure the expression matches exactly so
i cannot work out why the code will not run.

Assuming that your path table is named tblImagePaths and that the field is
named [Image Path] then you could just leave tblImagePaths out of the form's
recordsource entirely, and look it up as needed:

Me![Imagecontrol].Picture = DLookUp("[Image Path]", "tblImagePaths") &
Me![Picture]
 
J

John W. Vinson

Sorry John,

It's still not working. Do i need to put this new code as an 'OnCurrent'
event or somewhere else?

Sorry, yes - I intended On Current.

Please post your tablenames, fieldnames, controlnames and code if this isn't
working.
 
A

adrian007uk

Hi John

I have 2 tables. The first table is called 'Records'. It contains the
following:

Number: Auto number
Title: Text
Artist: Text
Picture: Text

This table has been populated with five (made up) records.

I have a second table called TbleImage Path. It has one field:
Image Path: Text

The tables are not linked.

The 'Picture' contained vinyl1.jpg etc

The 'Image Path' contained G:\Vinyl Images\

I then made a query (TbleImagePath Query):

Expr1: [Image Path] & "" & [Picture]

I unticked the image path and picture tick boxes just to show:
G:\Vinyl Images\vinyl1.jpg
G:\Vinyl Images\vinyl2.jpg

etc

I then made a form based on the 'Records' table. I then set the 'Picture'
field to look at the TbleImagePath Query).

This does not show the jpg.

If i type the full path G:\Vinyl Images\vinyl1 directly into the 'Picture'
record in the 'Records' table ands et the control source to'Picture' in the
'Records' form the jpg show up no problem.

The code i have used is the code(s) yop have posted but the debugger informs
me it cannot find either 'Image Path' or 'Picture' fields.

Adrian
 
A

adrian007uk

Hi Keith

Thanks for your contribution to my problem. John has been trying to help me
but i am willing to give your advice ago. Could you please tell me where i
should put your code i.e., in the query, the table, or the form?

Adrian

Keith Wilby said:
adrian007uk said:
I have read up on best practice conerning displaying images in a database.

I am planning to link the images from my PC. What i would like to know is
if the location of ther folder where the images are stotred changes (e.g.,
from 'C' to 'D') is there any way it can be changed within the database
quicly without having to change every image location as well?

Thanks in advance for any suggestions.

Just a thought, and I've not tested this so there might be a red herring
element, but if your images are all in the same generic location, eg
X:\MyFolder\MyImages\ ... then you *could* store this location in a lookup
table and use DLookup to return it. So in your query you could have a
calculated field

ImageLocation: DLookup("MyField", "tblMyTable") & [ImageFolder]

where [ImageFolder] is a field to store the " ... " element of
"X:\MyFolder\MyImages\ ... "

.... and if the location changes, say to X:\MyOtherFolder\MyImages\ ...

then you only need change it once in the lookup table.

Keith.
www.keithwilby.co.uk
 
A

adrian007uk

Hi John

I have posted my tablenames and fieldnames below. If it helps i can send my
database!

Adrian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top