meanster99
Meum cerebrum nocet!
- Local time
- Today, 19:03
- Joined
- May 2, 2006
- Messages
- 62
I copied and pasted all of the code from the Northwind sample database that allows you to add/change an employee's photo.
I checked I have all the same references and have declared all variables but I still get the error "Compile Error: Variable not defined" at :
FileDialog(msoFileDialogFilePicker)
I tried to declare a variable as a FileDialog but it wasnt recognised as a variable type! (i.e Dim fd As FileDialog - but the FileDialog stayed in black text not blue!)
Does anyone know why this is happening?
I checked I have all the same references and have declared all variables but I still get the error "Compile Error: Variable not defined" at :
FileDialog(msoFileDialogFilePicker)
I tried to declare a variable as a FileDialog but it wasnt recognised as a variable type! (i.e Dim fd As FileDialog - but the FileDialog stayed in black text not blue!)
Does anyone know why this is happening?
Code:
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