EzGoingKev
Registered User.
- Local time
- Today, 08:05
- Joined
- Nov 8, 2019
- Messages
- 178
Good morning all.
I have some code that updates some local tables from one Access db into another.
The source db is replaced with a new version monthly. The current file name is "VCdb_AUGUST_2021.accdb".
I added "VCdb_" to the table names in the destination db.
This is the code:
When I run this I am getting the following error message : "Could not find the file 'C:\Users\EzGoingKev\VCdb_AUGUST_2021.accdb'. I am not sure what is going on here. "C:\Users\EzGoingKev\" is not the location I specified as the filePath but "VCdb_AUGUST_2021.accdb" is the correct file name though.
Can anyone help me with this?
I have some code that updates some local tables from one Access db into another.
The source db is replaced with a new version monthly. The current file name is "VCdb_AUGUST_2021.accdb".
I added "VCdb_" to the table names in the destination db.
This is the code:
Code:
Option Explicit
Function UpdateVCdbTables()
On Error GoTo ErrorHandler
DoCmd.Hourglass (True)
DoCmd.SetWarnings (False)
Dim filePath As String: filePath = Dir("C:\Users\EzGoingKev\OneDrive - My Company Name\Access\@VCdb\VCdb_*.accdb")
Dim TU As TableDef
For Each TU In CurrentDb.TableDefs
If TU.Name Like "VCdb_*" Then
DoCmd.RunSQL "DELETE * FROM " & TU.Name
DoCmd.RunSQL "INSERT INTO " & TU.Name & " SELECT * FROM " & Mid(TU.Name, 6) & " IN " & filePath
End If
Next TU
Error_Exit:
Exit Function
ErrorHandler:
MsgBox Error$
Resume Error_Exit
End Function
When I run this I am getting the following error message : "Could not find the file 'C:\Users\EzGoingKev\VCdb_AUGUST_2021.accdb'. I am not sure what is going on here. "C:\Users\EzGoingKev\" is not the location I specified as the filePath but "VCdb_AUGUST_2021.accdb" is the correct file name though.
Can anyone help me with this?
Last edited: