insert image path to a table automatically (1 Viewer)

eshai

Registered User.
Local time
Today, 22:10
Joined
Jul 14, 2015
Messages
193
hi:
i have a table to store file path for images
"lastname" "firstname" "city" "image"
is there a way to auto insert the path of the image with name to the image field
(c:\students images\John Doe california.gif) by the value from the table

in regards eshai
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Try this:
Code:
"c:\students images\" & '" & firstname & "' & " " & '" & lastname & "' & " " & '" & city & "' & ".gif"

However, I suggest you remove the spaces e.g. c:\StudentImages\JohnDoeCalifornia.gif
 

eshai

Registered User.
Local time
Today, 22:10
Joined
Jul 14, 2015
Messages
193
Try this:
Code:
"c:\students images\" & '" & firstname & "' & " " & '" & lastname & "' & " " & '" & city & "' & ".gif"

you mean to put at in a query as expression on the image field?
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Not quite.
Use an update query to populate the image field with that expression in the Update To line
Check that you have data in both name fields & the city field for each student.
If there are any gaps, either omit that record or handle the issue using Nz functions.

However, just in case I've made a mistake ... or you do so copying the expression, first try it in a select query & check the results BEFORE running the update

Otherwise just concatenate the fields in an expression as you suggested. If so, you don't need to use the image field
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Post the query sql and I'll modify it for you
 

eshai

Registered User.
Local time
Today, 22:10
Joined
Jul 14, 2015
Messages
193
Post the query sql and I'll modify it for you

Code:
UPDATE test SET test.image = "C:\StudentsManager\data\Pictures\" & '" & lastname & "' & " " & '" & firstname & "' & " " & '" & city & "' & ".gif";

thank you
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Sorry. A few basic errors in my original version which i'll blame on answering on my phone. Corrected version which does work

Code:
UPDATE test SET test.[Image] = "C:\StudentsManager\data\Pictures\" & [lastname] & " " & [firstname] & " " & [city] & ".gif";

2 things:
1. I believe Image is a reserved word. Change it to ImagePath or similar
2. I strongly advise against having spaces in the image path file name to avoid paths like this
Code:
C:\StudentsManager\data\Pictures\White Jane Weston Super Mare.gif
This is better
Code:
C:\StudentsManager\data\Pictures\WhiteJaneWestonSuperMare.gif

But its still 'clunky'
Better still would be to use a unique StudentID field for the file name
e.g. if the studentID = "S11234" then the image path would be
Code:
C:\StudentsManager\data\Pictures\S11234.gif

HTH
 
Last edited:

eshai

Registered User.
Local time
Today, 22:10
Joined
Jul 14, 2015
Messages
193
perfect work great

i'm rebuilding a db the picture folder is 4gb so i can't change the structure

thank you for your help
best regards eshai
 

isladogs

MVP / VIP
Local time
Today, 20:10
Joined
Jan 14, 2017
Messages
18,186
Glad to have helped.
Good thing you weren't trying to store these using the dreaded attachment field.

BTW its really not too late to rename the image files
There are several free utilities which will allow you to batch rename files automatically even if you have many thousands of them
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:10
Joined
May 21, 2018
Messages
8,463
There are several free utilities which will allow you to batch rename files automatically even if you have many thousands of them
Yes I use the free Irfanview that will batch rename to include taking out spaces.
https://www.irfanview.com/
Free, light weight, and very functional. Batch conversion and batch rename.
 

Users who are viewing this thread

Top Bottom