Originally Posted by
hendrikbez
Hl orange
Went to bed and started to think about thisa,and I have a plan. I will make a new import button to show path at home. So one for work and one for home, but thank you for helping me with this.
Hi Hendrik!
Your plan is a very good solution, but, you could do something more automated.
In a standard code module, add this function:
Code:
Function MyImportsDrive() As String
Dim IES As ImportExportSpecification
Dim strDrive As String
If Environ("computername") = "MyHomeComputer" Then
strDrive = "c:\"
For Each IES In CurrentProject.ImportExportSpecifications
IES.XML = Replace(IES.XML, "d:\", strDrive)
Next IES
Else
strDrive = "d:\"
For Each IES In CurrentProject.ImportExportSpecifications
IES.XML = Replace(IES.XML, "c:\", strDrive)
Next IES
End If
MyImportsDrive = strDrive
End Function
(replace the red part with the actual name of your home computer)
Then, in the "On Load" event of the first form of your Access file, add these lines of code:
Code:
MsgBox "You are working on " & Environ("computername") _
& " computer and now your saved imports refers to " _
& MyImportsDrive & " drive.", vbInformation
So, every time you will be opening the Access file, the function "MyImportsDrive" will be rebuilding the path of the saved imports automatically, depending on the computer that will be running, and you don't have to thinking this issue when you go to bed.