On a form I have a command button that when clicked is supposed to take the user to...
It isn't doing this. Here is the code. Can someone tell me what I'm doing wrong?
Private Sub cmdAdd_Click()
' User asked to add a new photo
Dim strPath As String
' Grab a copy of the Office file dialog
' Select only one file
.AllowMultiSelect = False
' Set the dialog title
.Title = "Locate the image file"
' Set the button caption
.ButtonName = "Choose"
' Make sure the filter list is clear
' Add two filters
.Filters.Add "JPEGs", "*.jpg"
'.Filters.Add "Bitmaps", "*.bmp"
' Set the filter index to 2
.FilterIndex = 2
' Set the initial path name
.InitialFileName = "B:\Dropbox\Business Documents\Database\Database Images\"
' Show files as thumbnails
.InitialView = msoFileDialogViewThumbnail
' Show the dialog and test the return
If .Show = 0 Then
' Didn't pick a file - bail
' Should be only one filename - grab it
strPath = Trim(.SelectedItems(1))
' Set an error trap
On Error Resume Next
' Set the image
Me.txtImage = strPath
' Set the message in case Image control couldn't find it
Me.lblMsg.Caption = "Failed to load the picture you selected." & _
" Click Add to try again."
' Put focus in a safe place