David,
I managed to make it work... here's the modified code...
Apologies to Ken Getz for messing with his code, but it does what you want...
'---in a separate module....
Function TestIt() As Variant '<---changed the return type to Variant
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:\", _
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.
'---I bastardized this line...
TestIt = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
Debug.Print Hex(lngFlags)
End Function
button code on a form:
Option Compare Database
Option Explicit
Private Sub cmdTestIt_Click()
Dim varFile As Variant
varFile = TestIt()
If Not IsNull(varFile) Then
Me.txtFileName.SetFocus
Me.txtFileName.Text = varFile
End If
End Sub
Don't know if the function should return a string or not, but it *does* work...
HTH, and apologies for the butcher job...
Pieter