
Originally Posted by
Ruegen
I pasted (everything from the cmdPicker onclick event on your form) on the button onclick.
It comes up with this error
Am I missing something here?
I thought since I only need to save the path and take no other action
Your code copied
I added the dim
Code:
Dim strPath As String
' User asked to add a new photo
'Dim strPath As String
' Grab a copy of the Office file dialog
With Application.FileDialog(msoFileDialogFilePicker)
' Select only one file
.AllowMultiSelect = False
' Set the dialog title
.Title = "Locate a file to attach"
' Set the button caption
.ButtonName = "Choose"
' Make sure the filter list is clear
.Filters.Clear
' Add two filters
'.Filters.Add "JPEGs", "*.jpg"
.Filters.Add "All Files", "*.*"
' Set the filter index to 2
'.FilterIndex = 2
' Set the initial path name
'.InitialFileName = CurrentProject.Path & "\Pictures"
.InitialFileName = "C:\"
' Show files as thumbnails
.InitialView = msoFileDialogViewThumbnail
' Show the dialog and test the return
If .SHOW = 0 Then
' Didn't pick a file - bail
Exit Sub
End If
' Should be only one filename - grab it
strPath = Trim(.SelectedItems(1))
' Set an error trap
On Error Resume Next
' Set the image
'Me.txtPhoto = strPath
' Set the message in case Image control couldn't find it
'Me.lblMsg.Caption = "Failed to load the file you selected." & _
'" Click Picker to try again."
End With
' Put focus in a safe place
Me.SetFocus