Question : Get user input filename from DoCmd.OutputTo acReport, stDocName2, acFormatTXT

Hi im using the following in Access 2003:

DoCmd.OutputTo acReport, stDocName2, acFormatTXT

A dialog box opens and the user canhoose the filename, how can get the path+filename that the user chooses?

Answer : Get user input filename from DoCmd.OutputTo acReport, stDocName2, acFormatTXT

Perhaps what you need is a FolderPicker dialog instead.  That way you could select the folder, and then use an InputBox to get the file name (or, if it is always the same, just hard-code the file name).  Here is code for selecting a folder:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
Public Function SelectFolder() As String
'Requires Office XP (2002) or higher
'Requires a reference to the Microsoft Office Object Library
'Created by Helen Feddema 3-Aug-2009
'Last modified 3-Aug-2009
 
On Error GoTo ErrorHandler
 
   Dim strFolderPath As String
   Dim fd As Office.FileDialog
   
   'Create a FileDialog object as a Folder Picker dialog box.
   Set fd = Application.FileDialog(msoFileDialogFolderPicker)
   
   With fd
      .Title = "Browse for folder where Word templates are located"
      .ButtonName = "Select"
      .InitialView = msoFileDialogViewDetails
      '.InitialFileName = strPath
      If .Show = -1 Then
         strFolderPath = CStr(fd.SelectedItems.Item(1)) & "\"
      Else
         Debug.Print "User pressed Cancel"
         strFolderPath = ""
      End If
   End With
 
   SelectFolder = strFolderPath
   
ErrorHandlerExit:
   Exit Function
 
ErrorHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
   Resume ErrorHandlerExit
 
End Function
Random Solutions  
 
programming4us programming4us