Setting default path to find files

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Im using some code that I picked up from a previous posting to retrieve a
file location but was wondering if there is someway to have the search
function start at a specific folder each time. The code I have now is:
strFilter = ahtAddFilterItem(strFilter, "All Files (*.jpg)","*.jpg")
I need to to go to a folder such as:
G:\DC_Public\Photos\
so that they dont have to spend alot of time building the path. I know there
is an InitalDir: function but Im not sure where to put it.
 
If you're using the code at ...

http://www.mvps.org/access/api/api0001.htm

.... then the InitialDir optional argument is used to set the starting folder
....

Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:\", _ '<-
change this to your folder name
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
 
I modified it a little bit, so there is no message box. Instead the path is
populating a field. Here is what I have and Im not sure where to put the
InitalDir at.
strFilter = ahtAddFilterItem(strFilter, "All Files (*.jpg)", "*.jpg")
Debug.Print Hex(lngFlags)
[Text6].Value = ahtCommonFileOpenSave
 
Try:

[Text6].Value = ahtCommonFileOpenSave( _
InitialDir:="G:\DC_Public\Photos\", _
Filter:=strFilter, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hendricks97 said:
I modified it a little bit, so there is no message box. Instead the path is
populating a field. Here is what I have and Im not sure where to put the
InitalDir at.
strFilter = ahtAddFilterItem(strFilter, "All Files (*.jpg)", "*.jpg")
Debug.Print Hex(lngFlags)
[Text6].Value = ahtCommonFileOpenSave

Brendan Reynolds said:
If you're using the code at ...

http://www.mvps.org/access/api/api0001.htm

.... then the InitialDir optional argument is used to set the starting
folder
....

Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda,
*.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)",
"*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)",
"*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
MsgBox "You selected: " & ahtCommonFileOpenSave(InitialDir:="C:\", _
'<-
change this to your folder name
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
 
Back
Top