Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / October 2005

Tip: Looking for answers? Try searching our database.

How to get a file name by browsing a specific folder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nuno Guerra - 31 Oct 2005 16:35 GMT
Hi! First off all congratulations for you all by make this discussion group
so helpfull.

I would like to add a button in my form to open a dialog box, browse a
specific folder, choose any file and then change the value of a text box in
my form with the filename I had choosed in the browser.

I have a text box that will be populate with the filename I choosed from the
browser.

I saw the Georgie's thread on 10/5/2005 but I don't know
if the solutions presented are the same for my question.
Douglas J Steele - 31 Oct 2005 16:45 GMT
Take a look at http://www.mvps.org/access/api/api0001.htm

The 4 line example at the start of the page shows how you'd get the filename
in a variable using the code on the rest of the page:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
               Filter:=strFilter, OpenFile:=True, _
               DialogTitle:="Please select an input file...", _
               Flags:=ahtOFN_HIDEREADONLY)

Once you've got the filename in a variable, you can plug that value into a
text box using code like:

Me.txtFilename = strInputFileName

(where txtFilename is the name of a text box on your form)

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi! First off all congratulations for you all by make this discussion group
> so helpfull.
[quoted text clipped - 8 lines]
> I saw the Georgie's thread on 10/5/2005 but I don't know
> if the solutions presented are the same for my question.
Nuno Guerra - 31 Oct 2005 17:14 GMT
Thanks a lot. It works!!

I would like to ask just a last question:
For default, this code browses a window in "My Documents". How can I
pre-define a specific location by default?

Thanks again.

> Take a look at http://www.mvps.org/access/api/api0001.htm
>
[quoted text clipped - 32 lines]
> > I saw the Georgie's thread on 10/5/2005 but I don't know
> > if the solutions presented are the same for my question.
Nuno Guerra - 31 Oct 2005 17:22 GMT
Douglas, I think I just found it:
Is in ahtCommonFileOpenSave Function.

I have to change this line "If IsMissing(InitialDir) Then InitialDir = CurDir"
and change the CurDir Value for the folder's name string, am I correct?

> Thanks a lot. It works!!
>
[quoted text clipped - 40 lines]
> > > I saw the Georgie's thread on 10/5/2005 but I don't know
> > > if the solutions presented are the same for my question.
Douglas J Steele - 31 Oct 2005 18:23 GMT
Actually, it's even simpler than that.

You simply have to pass a value for InitialDir when you call the function.

Take a look at the function GetOpenFile that's defined in the stuff you
copied from that page. It shows using that parameter.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Douglas, I think I just found it:
> Is in ahtCommonFileOpenSave Function.
[quoted text clipped - 46 lines]
> > > > I saw the Georgie's thread on 10/5/2005 but I don't know
> > > > if the solutions presented are the same for my question.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.