Hi,
I have been using the following code for some time to allow me to transfer data to an upgraded version of the database. See code snippet 1 below.
Basically it determines the existing Desktop file path.
I now want to change it to all me to transfer the data to a DB in the same folder as the open DB. I have the following code that seems to work, I just need to know if there are any issues I should consider that I have not in the code below.
Do I really need the following part.....
If Dir$(sUpgradePath, vbDirectory) = "" Then
sUpgradePath = Environ("UserProfile") & "\Desktop\" 'For use with Vista/Win7
End If
Is there any possibility that Access just would not be able to work out the directory path ?
Any advice would be greatly appreciated.
Kev
'********************code snippet 1 ****************************On Error GoTo Err_HandlerDim RS As DAO.Recordset, sSql As String, strQuestion As String, sUpgradePath As String DoCmd.SetWarnings False'Determine user Desktop path sUpgradePath = "c:\Desktop\" 'For use with WinXP on DRN If Dir$(sUpgradePath, vbDirectory) = "" Then sUpgradePath = Environ("UserProfile") & "\Desktop\" 'For use with Vista/Win7 End If sUpgradePath = sUpgradePath & DLookup("SysUpgradeTitle", "systblVersion", "")'************************* code snippet 2 **************************************'Determine current path sUpgradePath = CurrentProject.path 'Check for terminating backslash sUpgradePath filepath. If Right(sUpgradePath, 1) <> "\" Then sUpgradePath = sUpgradePath & "\" End If If Dir$(sUpgradePath, vbDirectory) = "" Then sUpgradePath = Environ("UserProfile") & "\Desktop\" 'For use with Vista/Win7 End If
I just realized that I should reorder the sequence as follows. Any other suggestions ???
Kev
'Determine current path sUpgradePath = CurrentProject.path If Dir$(sUpgradePath, vbDirectory) = "" Then sUpgradePath = Environ("UserProfile") & "\Desktop\" End If 'Check for terminating backslash sUpgradePath filepath. If Right(sUpgradePath, 1) <> "\" Then sUpgradePath = sUpgradePath & "\" End If sUpgradePath = sUpgradePath & DLookup("SysUpgradeTitle", "systblVersion", "")
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
I just realized that I should reorder the sequence as follows. Any other suggestions ???
Kev
Open in new window