append suffix to a string

scoob8254

Registered User.
Local time
Today, 02:00
Joined
Mar 2, 2008
Messages
76
hi

i have 2 tables tblSubCatch and tblCatch both have a field called image which hold image names

when images are selected they are copied to a specific folder and then their filename entered into the fields, what i wanted to happen is if the image name already excists in either table then the string which holds the image name before its copied has a number appended to it,

i managed to get something going using "if" but say i copied the same image 3 times to test it i would end up with something like test1,jpg test12.jpg, test123,jpg instead of test1.jpg, test2.jpg and test3.jpg

can anybody point me to an example of what im trying to achieve, ive definatly seen one but not sure if its on this site, or can anybody tell me a better way to acheieve what im trying to do,
 
Last edited:
Your question is not quite clear.

Do you want to replace the name in the field with the later revision?
image.jpg becomes image1.jpg then image2.jpg

Or do you want:
image.jpg to become image.jpg, image1.jpg
 
sorry yeah not the best explanation :)

if the image name already excists i wanted it renaming, so if theirs an image called test.jpg but it already excists in the tables it would become test1.jpg or if this already excists it becomes test2.jpg so it becomes a later revision if u like.

only reason id like to do this is most digital cameras use re accuring filenames and if u delete the images then they restart at say image1 again so id like to guard against the db overwriting images when it copies the file if the user is too lazy to rename them
 
if the image name already excists i wanted it renaming, so if theirs an image called test.jpg but it already excists in the tables it would become test1.jpg

I expected this but it is always good to be sure.

Your code doesn't need a lot of modification. From your first post it appears you are able to parse strings, separating the filename and extension at the dot. Did you write this code or at least understand it if you got it from someone else? It will have a way of dividing using the dot. The two parts of filename will become variables somewhere in the code.

The code is apparently also finding the existing last character and incrementing it. Somewhere it will concatenate this incremented variable to the original filename. You just need to concatenate it to the part of the filename without the appended version number rather than the full existing name.

Without knowing the precise code it is difficlult to suggest exactly what you need to do.

However you might consider using an underscore between the original filename and the version number (eg image_1.jpg), This would make it easier to parse.

In this case the concatenation might look something like:

strNewName = strFilebase & "-" & strVersion & "." & strExtension
 
thanks for your post, looking at your example realised why im making it difficult for myself and your prob right, adding an underscore will make it easier
 

Users who are viewing this thread

Back
Top Bottom