Question : ahtcommonfileopensave access 2003 to my compu

Hello,
I am using the code below to get a file but I want the file dialog box to open to my computer how do I alter the code. I know I have to change the strStartDir  to equal my computer but I am not sure how.

Thanks

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
Dim DeleteFiles As QueryDef
Dim AddFiles As QueryDef
Dim strStartDir As String
Dim lngFlags As Long
Dim File_Name As String
 
strStartDir = "D:"
 
File_Name = ahtCommonFileOpenSave(InitialDir:=strStartDir, FilterIndex:=3, Flags:=lngFlags, DialogTitle:="Select File")

Answer : ahtcommonfileopensave access 2003 to my compu

Are you using the old CommonDialog control?  That is no longer needed, since Office XP introduced the FileDialog object.  Here is some code that retrives the selected folder using this object.  You can set the InitialFileName argument to whatever you want (the default is the My Documents 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:
38:
39:
40:
41:
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
   Dim strPath As String
 
   'Create a FileDialog object as a Folder Picker dialog box.
   Set fd = Application.FileDialog(msoFileDialogFolderPicker)
 
   'Set strPath to the folder you want to open initially
   strPath = "G:\Data"
 
   With fd
      .Title = "Browse for folder where _________ 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