none
Change File Names Using SQL Query to get new UID RRS feed

  • Question

  • Hello

    I have a problem using VBA as  i am fairly new to this VB. What i have is a folder of .JPG Files that have UID numbers for the file names, these have recently changed in the database as the People in the photographs have changed departments and OU in AD. They have been assigned new UID numbers. Using SQL i can join tables to come up with the new numbers for each person, I think there must be a way using Access to loop through the Folder and rename the files with the new UID's.

    Can anyone provide me some snippets that could do this. Please respond with questions for more detailed information as i do not want my initial question to seem to long winded and complex.

    Tuesday, August 12, 2014 1:32 PM

All replies

  • Hi Yunewaal,
     
    You can use the VBA Name statement to rename files looping through the
    recordset returned by the query you mentioned:
     
    Name rs.Fields("OldFileName") As rs.Fields("NewFileName")
     
    Note that this will potentially fail if a new UID matches an existing old UID!!
     
     

    Regards, Jan Karel Pieterse|Excel MVP|http://www.jkp-ads.com
    Tuesday, August 12, 2014 2:27 PM