MS Access Office 365
Part of the cat rescue organisation database I am working on has a form with a picture box. The picture box is supposed to show the image hyperlinked in the PhotLink field; i.e. the photo of the cat. The field is visible on the form so you can click on the hyperlink and get the bigger picture. That works ok but if you are flicking through the records, this slows the process down a lot.
The file path to the picture is put into the Photolink field by executing a procedure when a button (Get Photo Link) is clicked on with the mouse. The control source for the image is the PhotoLink field. Not sure if Get Focus comes into play here.
The adapted procedure below (thanks to others) performs this function, but I do not know why the image is not automatically placed in the picture box.
Private Sub Command317_Click()
'First, set a Reference to the Microsoft Office XX.X Object Library
Dim strButtonCaption As String, strDialogTitle As String
Dim strHyperlinkFile As String
Const msoFileDialogFilePicker As Long = 3
Dim FD As Object
Dim file As Variant
Set FD = Application.FileDialog(msoFileDialogFilePicker)
strButtonCaption = "Save Hyperlink"
strDialogTitle = "Select File to Create Hyperlink to Photo Link"
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.Filters.Clear
.Filters.Add "All Files", "*.*"
.AllowMultiSelect = False
.FilterIndex = 1 'Database files
.ButtonName = strButtonCaption
.Title = strDialogTitle
If .Show Then
For Each varItem In .SelectedItems 'There will only be 1
'Extract Caption and and add Address of Hyperlink (Caption#Address)
strHyperlinkFile = Mid$(varItem, InStrRev(varItem, "") + 1) & "#" & varItem
Me![PhotoLink] = strHyperlinkFile
Next varItem
End If
End With
End Sub
I think maybe by using the button to fill the PhoLink box I haven't told the picture box that something is in there. The format of the PhotoLink field is as hyperlink.
Can I have some help with this please?
Thanks.