File Dialog in access 2007

S

stumpy

Im having problems with the following code in access 2007.
I'm trying to open a file dialog to place an image into a form.
Any help would be appreciated

Reghards Rob.

Sub getFileName()
' Displays the Office File Open dialog to choose a file name
' for the current id record. If the user selects a file
' display it in the image control.
Dim fileName As String
Dim result As Integer

With Application.FileDialog(MsoFileDialogOpen)

.Title = "Select Picture"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Images", "*.jpeg;*.jpg;*.bmp", 1
.Filters.Add "All Files", "*.*"
.InitialFileName = "C:\Users\Rob\My Pictures"
result = .Show
If (result <> 0) Then
fileName = Trim(.SelectedItems.Item(1))

Me![ImagePath].Visible = True
Me![ImagePath].SetFocus
Me![ImagePath].Text = fileName
Me![Exit].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