Greetings,
I have a BE database, that when opened, opens a form for saving the results of a query to a text file on the desktop.
It works fine, if the full path is entered.
The problem is, I want this saved on any users' desktop.
I did some digging and found the %userprofile% variable, which when used, gives me the error.
I understand this should work in both Windows XP and Windows 7, which are the environments the full DB will operate in.
So far the "EXPORT" button on the form has the following for the code:
When I tried this:Code:Private Sub BTN_Export_Click() DoCmd.TransferText acExportDelim, , "QRY_ExportPublicComment", "C:\Users\Mark N. McAllister\Desktop\PubComExp.txt" End Sub
the error occurs.Code:Private Sub BTN_Export_Click() Dim strPath As String strPath ="%userprofile%\desktop\PubComExp.txt" DoCmd.TransferText acExportDelim, , "QRY_ExportPublicComment", strPath End Sub
What's wrong?
TIA
MNM


Reply With Quote


