getting a string into a textbox on form

G

Guest

I have successfully used the method at:
http://www.mvps.org/access/api/api0001.htm
to create a browse function for my form.(User can browse to find the name of
an image file he wants to include in the table the form is based upon.)

All I need to do is get the name of the file the user browses to and selects
into a text box on my form (so that it can be written to the table).

To enable the browsing by the user, I put the following code into the 'on
click' event of a button on the form. (I also created a 'Browse File' module
per instructions on web page above.)

I figured the "strInputFileName" contains the name of the file...but how do
I put that into the text box on the form? (I know it's something real basic I
am asking.Just can't find the answer by searching the help files using my
keywords)


****begin code******
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
****end code******

Thanks much,
Paul
 
G

Graham Mandeno

Hi Paul

If Len(strInputFileName) <> 0 Then
Me.[name of textbox] = strInputFileName
End If

The reason to check the length first is that if the user clicks the Cancel
button, the function will return a zero-length string. In this case, you
presumably do not want to overwrite the previous contents of the textbox.
 

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