J jo15765 Registered User. Local time Today, 15:03 Joined Jun 24, 2011 Messages 130 May 7, 2020 #1 How can I search all tables in my database for a table named *DavidsData and rename it to _DavidsDataLocal through VBA?
How can I search all tables in my database for a table named *DavidsData and rename it to _DavidsDataLocal through VBA?
theDBguy I’m here to help Staff member Local time Today, 15:03 Joined Oct 29, 2018 Messages 22,771 May 7, 2020 #2 Hi. I think there is an add-in that can help you do that. However, I would caution you because changing the table's name might affect other objects in your database project.
Hi. I think there is an add-in that can help you do that. However, I would caution you because changing the table's name might affect other objects in your database project.
J jo15765 Registered User. Local time Today, 15:03 Joined Jun 24, 2011 Messages 130 May 7, 2020 #3 an add-in that can be run through vba? I was hoping to run this solely through vba code... I feel it will be something along the lines of this, altho this does not allow me to specify a table name with wild cards... Code: For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 10) <> "MSys" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Maybe something like this Code: For Each tdf In CurrentDb.TableDefs If Right(tdf.Name, 10) = "DavidsData" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Last edited: May 7, 2020
an add-in that can be run through vba? I was hoping to run this solely through vba code... I feel it will be something along the lines of this, altho this does not allow me to specify a table name with wild cards... Code: For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 10) <> "MSys" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Maybe something like this Code: For Each tdf In CurrentDb.TableDefs If Right(tdf.Name, 10) = "DavidsData" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next
theDBguy I’m here to help Staff member Local time Today, 15:03 Joined Oct 29, 2018 Messages 22,771 May 7, 2020 #4 jo15765 said: an add-in that can be run through vba? I was hoping to run this solely through vba code... Click to expand... Maybe, maybe not. I haven't used the add-in to say for sure. jo15765 said: I feel it will be something along the lines of this, altho this does not allow me to specify a table name with wild cards... Code: For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 10) <> "MSys" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Maybe something like this Code: For Each tdf In CurrentDb.TableDefs If Right(tdf.Name, 10) = "DavidsData" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Click to expand... What happened when you tried that?
jo15765 said: an add-in that can be run through vba? I was hoping to run this solely through vba code... Click to expand... Maybe, maybe not. I haven't used the add-in to say for sure. jo15765 said: I feel it will be something along the lines of this, altho this does not allow me to specify a table name with wild cards... Code: For Each tdf In CurrentDb.TableDefs If Left(tdf.Name, 10) <> "MSys" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Maybe something like this Code: For Each tdf In CurrentDb.TableDefs If Right(tdf.Name, 10) = "DavidsData" Then tdf.Name = tdf.Name & "_DavidsDataLocal" End If Next Click to expand... What happened when you tried that?
J jo15765 Registered User. Local time Today, 15:03 Joined Jun 24, 2011 Messages 130 May 7, 2020 #5 When I ran my second VBA syntax it worked, but not sure if I am not thinking of, or not aware of, any use cases that could cause this to fail?
When I ran my second VBA syntax it worked, but not sure if I am not thinking of, or not aware of, any use cases that could cause this to fail?
theDBguy I’m here to help Staff member Local time Today, 15:03 Joined Oct 29, 2018 Messages 22,771 May 7, 2020 #6 jo15765 said: When I ran my second VBA syntax it worked, but not sure if I am not thinking of, or not aware of, any use cases that could cause this to fail? Click to expand... It might fail if you have more than one table that ends with "DavidsData."
jo15765 said: When I ran my second VBA syntax it worked, but not sure if I am not thinking of, or not aware of, any use cases that could cause this to fail? Click to expand... It might fail if you have more than one table that ends with "DavidsData."