Access Quickie

Soldato
Joined
8 Oct 2005
Posts
4,184
Location
Midlands, UK
Not used Access in years, can some help me out?

I have a field (called ImagePath) in a table with the following info:

Code:
C:\Documents and Settings\user\My Documents\WEB PICTURES\RPB125.jpg

I need to run some sort of update query that stripts evertything away bar the actual image file - RPB125.jpg.

Can anyone help?
 
PHP:
UPDATE [Table] SET ImagePathNoSlash = RIGHT(ImagePath, LEN(ImagePath)-INSTRREV(ImagePath, "\"))

INSTRREV(ImagePath, "\") finds the last '\' character's position, i.e. 30. INSTR would find the first '\' character.

LEN(ImagePath)-INSTRREV(ImagePath, "\") finds how many characters the filename is by taking the length of the whole path, i.e. 50 - the length of the characters after the final '\', i.e. 30 = 20

RIGHT(ImagePath, LEN(ImagePath)-INSTRREV(ImagePath, "\")) returns 20 characters (the length of the filename) from the right of the string, i.e. only the filename nothing else.
 
Last edited:
Back
Top Bottom