I have the following code:
sqlstr = "Select Associate_ID, [Associate_First_Name] & ' ' & [Associate_Last_Name] AS OthAssocNo
FROM NewAssociates"
Set rst1 = db.OpenRecordset(sqlstr, dbOpenDynaset, dbSeeChanges)
rst1.MoveFirst
Do While Not rst1.EOF
oldname = "c:\Photos\" & rst1("OthAssocNo") & ".jpg"
newname = "c:\Photos\" & rst1("Associate_ID") & ".jpg"
If Dir(oldname) <> "" Then
Name oldname As newname
'FileCopy
End If
rst1.MoveNext
Loop
This picks up the old FirstName & ' ' & LastName , which matches the name of their picture, looks for the picture and replaces the number with the new associate ID.
I now have to make it work with pictures that have the naming convention of FirstName & ' ' & LastName & <some random characters> & .jpg
Is there some way to use a wildcard in the oldname line so that I can get the entire name using the first and last names?
sqlstr = "Select Associate_ID, [Associate_First_Name] & ' ' & [Associate_Last_Name] AS OthAssocNo
FROM NewAssociates"
Set rst1 = db.OpenRecordset(sqlstr, dbOpenDynaset, dbSeeChanges)
rst1.MoveFirst
Do While Not rst1.EOF
oldname = "c:\Photos\" & rst1("OthAssocNo") & ".jpg"
newname = "c:\Photos\" & rst1("Associate_ID") & ".jpg"
If Dir(oldname) <> "" Then
Name oldname As newname
'FileCopy
End If
rst1.MoveNext
Loop
This picks up the old FirstName & ' ' & LastName , which matches the name of their picture, looks for the picture and replaces the number with the new associate ID.
I now have to make it work with pictures that have the naming convention of FirstName & ' ' & LastName & <some random characters> & .jpg
Is there some way to use a wildcard in the oldname line so that I can get the entire name using the first and last names?