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 / March 2005

Tip: Looking for answers? Try searching our database.

Adding a file path to a form field using CommonDlg

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MrMibs - 30 Mar 2005 00:47 GMT
Hi,
I'm and experienced developer new to Access programming.
I created a form that has a text box field for a file path. I'm trying to
get the filepath into the field using VBA and can't get it to work. (I want
the user to be able to browse for the file - and then I'll grab the path from
the dialog's FileName property) I'm calling the CommonDlg API when a Command
button is pressed on the form, and trying to set the Fieldname.Text to the
FileName property of the dialog after the user selects a file and presses
Open. I am expecting to see the filename in the field but it remains blank.
On VB forms all one has to do is Set textbox.text = FIleName and it would
immediately update the textbox on the form. Obviously this is not the way to
do it in Access.
Here is a code snipet:
'All the API code for CommonDlg is in a class module
Private Sub BrowseBtn_Click()
 
   Dim cdl As CommonDlg
   Set cdl = New CommonDlg
   cdl.Filter = "Adobe Files (*.pdf)|" & "*.pdf"
   cdl.FilterIndex = 1
   cdl.ShowOpen
   Doc_Name.Text = cdl.FileName 'Doc_Name is field in the DB
   Set cdl = Nothing
 
   
End Sub
Help on this would be greatly appreciated.
Signature

MrMibs

PC Datasheet - 30 Mar 2005 03:32 GMT
The CommonDlg API is buggy! Go to www.mvps.org/access and look at the API
section. Use the first example there.

--
                                       PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
                             resource@pcdatasheet.com
                                www.pcdatasheet.com

> Hi,
> I'm and experienced developer new to Access programming.
[quoted text clipped - 24 lines]
> --
> MrMibs
 
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.