Just a couple of questions:
- What is
fso
set to?
- What is
txtsourcedatabasefile
set to?
That is, I suspect, where your problem lies. I'd be looking at fso
myself to make sure you've set it.
Update:
In your question updates, your code:
Dim fso As FileSystemObject
creates the object but you don't actually initialize it to anything. You need to do:
Dim fso As FileSystemObject
Set fso = New FileSystemObject
This is actually preferable in the vast majority of the cases since the near-equivalent:
Dim fso As New FileSystemObject
creates an auto-instantiating object, meaning every time you use it, it will check to see if it needs to be created.
That makes a code segment like:
Dim fso As New FileSystemObject
fso.DoThis()
fso.DoThat()
if fso.EverythingDone then
fso.Shutdown()
end if
expensive since it will check fso
four times to see if it exists (and create it only the first time). It's more efficient to create it manually once.