Adding a file path to a form field using CommonDlg

G

Guest

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.
 

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