Get File Name

G

Guest

I need to put a button on a form that will open a File Lookup Window so the
use can open a file on another drive.

My application is in Access 2000.
I found the following code in Access 2003 and I tried using it in 2000 and I
get the error Method or data member not found.

Here is the two step process I'm trying to use:

Private Sub AddDoc_Click()
getFileName
End Sub

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current employee record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub
 
G

Guest

When I try this it returns an error on the "ahtAddFilterItem"
Sub or Function not defined.

When I dropdown the available references there is nothing like it - do you
know which reference to check in Access 2000.

Thanks




Alex Dybenko said:
hi,
you can use this API functions:
http://www.mvps.org/access/api/api0001.htm

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Dan @BCBS said:
I need to put a button on a form that will open a File Lookup Window so the
use can open a file on another drive.

My application is in Access 2000.
I found the following code in Access 2003 and I tried using it in 2000 and
I
get the error Method or data member not found.

Here is the two step process I'm trying to use:

Private Sub AddDoc_Click()
getFileName
End Sub

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current employee record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub
 
D

Douglas J. Steele

Sounds as though you didn't copy all of the code from the cited page.

You need to copy everything between the Code Start and Code Ends lines into
a new module (not a class module nor a module associated with a form).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan @BCBS said:
When I try this it returns an error on the "ahtAddFilterItem"
Sub or Function not defined.

When I dropdown the available references there is nothing like it - do you
know which reference to check in Access 2000.

Thanks




Alex Dybenko said:
hi,
you can use this API functions:
http://www.mvps.org/access/api/api0001.htm

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com


Dan @BCBS said:
I need to put a button on a form that will open a File Lookup Window so
the
use can open a file on another drive.

My application is in Access 2000.
I found the following code in Access 2003 and I tried using it in 2000
and
I
get the error Method or data member not found.

Here is the two step process I'm trying to use:

Private Sub AddDoc_Click()
getFileName
End Sub

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current employee record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer
With Application.FileDialog(msoFileDialogFilePicker)
.Title = "Select Employee Picture"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "Bitmaps", "*.bmp"
.FilterIndex = 3
.AllowMultiSelect = False
.InitialFileName = CurrentProject.Path
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))
Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![FirstName].SetFocus
Me![ImagePath].Visible = False
End If
End With
End Sub
 

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