i have foud the following code on the access web and want to extract the file
name and path which is output to the msgbox. can anybody help extract the
variable to be saved in a control.
i have attached the event to the onclick event which triggers the file
search but does not save the variable for later use.
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
Dim FleNme As String
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:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
FleNme = lngFlags
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function
Douglas J. Steele - 02 Jul 2007 13:42 GMT
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
Dim FleNme As String
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 (*.*)", "*.*")
FleNme = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
FleNme = lngFlags
MsgBox "You selected: " & FleNme
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
Debug.Print Hex(lngFlags)
End Function

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
>i have foud the following code on the access web and want to extract the
>file
[quoted text clipped - 24 lines]
> Debug.Print Hex(lngFlags)
> End Function
Daniel - 02 Jul 2007 13:44 GMT
ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
Returns the filename/path of the file selected by the users.
Use can use the Dir Function to extract the filename from the full path.
So your best bet is to set the ahtCommonFileOpenSave(...) to a variable and
then manipulate the variable as required.
Here's a sample I use for images.
Dim strFilter As String
Dim lngFlags As Long
Dim Docpath, FileName, StartDir, driveletter As String
strFilter = ahtAddFilterItem(strFilter, "Images Files",
"*.gif;*.jpeg;*.jpg;*.bmp;*.tif")
StartDir = "c:\"
Docpath = ahtCommonFileOpenSave(InitialDir:=StartDir,
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, DialogTitle:="Select
Document")
If Not Docpath = "" Then
FileName = Dir(Docpath)
Me.imgPath = Docpath
End If

Signature
Hope this helps,
Daniel P
> i have foud the following code on the access web and want to extract the file
> name and path which is output to the msgbox. can anybody help extract the
[quoted text clipped - 22 lines]
> Debug.Print Hex(lngFlags)
> End Function