M
mf_sina
Hi!
I don't know what's the problem with this ordeal in ms access. I saw in
northwind.mdb (samples of ms access) a form for employees. Every employee
has an image file for him/herself.
The form has 2 buttons: Add/Change and Remove.
When I click the button Add/Change, an open file dialog pops up and I can
browse for my image. But I tried to design the same thing in my own
database. but it returns an error:
Compile error: Variable not defined (msoFileDialogFilePicker)
even I copied the entire form of customers and even it's table from
northwind.mdb to my databse but it again returns error. Now it seems to me
that there is a component in Northwind.mdb that file dialog works with but
in my database that component doesn't exist and so i see the error.
Now I appreciate if someone could tell me should I import or do something
special to have that component work in my own database.
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
I don't know what's the problem with this ordeal in ms access. I saw in
northwind.mdb (samples of ms access) a form for employees. Every employee
has an image file for him/herself.
The form has 2 buttons: Add/Change and Remove.
When I click the button Add/Change, an open file dialog pops up and I can
browse for my image. But I tried to design the same thing in my own
database. but it returns an error:
Compile error: Variable not defined (msoFileDialogFilePicker)
even I copied the entire form of customers and even it's table from
northwind.mdb to my databse but it again returns error. Now it seems to me
that there is a component in Northwind.mdb that file dialog works with but
in my database that component doesn't exist and so i see the error.
Now I appreciate if someone could tell me should I import or do something
special to have that component work in my own database.
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