Help with Returned Result

G

Guest

I downloaded the File Picker routine from Ken Getz:
http://www.mvps.org/access/api/api0001.htm and put it into my database. this
is called when the users clicks a cmd button so they can pick a file. the
result of this pick should be put into a text box on the same form, so it
can be saved in the database. If I debug it, I see where the TestIt function
gets the right result, but how do i get that information into the TextBox?
(called PicPath) I actually have 3 access books and I'm still getting
nowhere. Any help offered would achieve hero status for at least 24hours!
Thank you.... here is the code:
Function TestIt()
Dim strFilter As String
Dim lngFlags As Long
Dim strInputFileName As String

'Modified 5/3/5 AMc
strFilter = ahtAddFilterItem(strFilter, "Jpeg Files (*.jpg)", "*.JPG")

'strFilter = ahtAddFilterItem(strFilter, "Gif Files (*.gif)", "*.GIF")
'strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
'strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")

strInputFileName = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Please Choose Your File:")
' Since you passed in a variable for lngFlags,
' the function places the output flags value in the variable.
MsgBox " " & strInputFileName & " from TestIt"
TestIt = strInputFileName
Debug.Print Hex(lngFlags)
End Function
 
G

George Nicholson

1) In the code for your command button Click event:
Private Sub cmdMyButton_Click()
Me.txtPicPath = TestIt
End Sub
Make sure this code is "attached" to the OnClick property of the button.

2) Just to be safe, change
Function TestIt()
to
Function TestIt() As String
As written, TestIt is returning a Variant variable. It never hurts to be
specific.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top