Hi,
I was using OLE object link to link pictures into my database, which is done manually, I was having a look through the example database of Northwind, the Employees form has an Add/Change button and a remove button for pictures, this process is much simplier and less time consuming. The picture is stored as text in the table therefore taking less space, my database is massive in size now because the pictures as saved as OLE objects in the table.
I have no idea how this code works, but I really want to use it. I have attempted to copy of the VBA code however it dosent work, as I keep on getting a bug as highlighted in red below. I was woundering if someone could explain the code to me, please see below.
This VBA is linked to the Add/Change button
Private Sub AddPicture_Click()
getFileName
End Sub
This is the VBA that runs of the VBA above.
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 Driver 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
The code highlighted in red is a bug, I think it is trying to lookup a reference or file.
Can someone please help mee?
I was using OLE object link to link pictures into my database, which is done manually, I was having a look through the example database of Northwind, the Employees form has an Add/Change button and a remove button for pictures, this process is much simplier and less time consuming. The picture is stored as text in the table therefore taking less space, my database is massive in size now because the pictures as saved as OLE objects in the table.
I have no idea how this code works, but I really want to use it. I have attempted to copy of the VBA code however it dosent work, as I keep on getting a bug as highlighted in red below. I was woundering if someone could explain the code to me, please see below.
This VBA is linked to the Add/Change button
Private Sub AddPicture_Click()
getFileName
End Sub
This is the VBA that runs of the VBA above.
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 Driver 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
The code highlighted in red is a bug, I think it is trying to lookup a reference or file.
Can someone please help mee?