I am making a small game for a work project using Microsoft Access for Office 365. I have a table with all of the answers and a related pic stored as an attachment. Users will scroll through records supplied via the Record Source via SQL query.
I want to display the image related to each record as the user navigates.
I would prefer to store the images elsewhere, but not all intended users have access to a common network folder. I do have access to common SharePoint location where I can upload their results in a linked SharePoint list, but when I attempt to insert an image from a SharePoint location, MS Access does not allow "web addresses".
In testing, I was using VBA to display the image (hosted on a network folder) as the background via the Picture Property on a sub-form, but because not all users have access to a common network folder, I can't do this in production. (Discovered there was no common folder after I created this.)
How do I display that picture in the attachment?
OR
How do I use SharePoint to host the images?
Are either of these things possible with 'out of the box' MS Access?
edit: using .accdr format to prevent users from looking at the answers in the tables
As you will have URLs to the pictures, you can use my fancy function UrlContent :
' Download (picture) file from a URL of a hyperlink field to a
' (temporary) folder, and return the full path to the downloaded file.
'
' This can be used as the control source for a bound picture control.
' If no Folder is specified, the user's IE cache folder is used.
'
' Typical usage in the RecordSource for a form or report where Id is
' the unique ID and Url is the hyperlink field holding the URL to
' the picture file to be displayed:
'
' - to a cached file where parameter Id is not used:
'
' Select *, UrlContent(0, [Url]) As Path From SomeTable;
'
' - or, where Id is used to create the local file name:
'
' Select *, UrlContent([Id], [Url], "d:\somefolder") As Path From SomeTable;
'
' Then, set ControlSource of the bound picture control to: Path
'
' 2017-05-28. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function UrlContent( _
ByVal Id As Long, _
ByVal Url As String, _
Optional ByVal Folder As String) _
As Variant
Const NoError As Long = 0
Const Dot As String = "."
Const BackSlash As String = "\"
Dim Address As String
Dim Ext As String
Dim Path As String
Dim Result As String
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
If Folder = "" Then
' Import to IE cache.
Result = DownloadCacheFile(Address)
Else
If Right(Folder, 1) <> BackSlash Then
' Append a backslash.
Folder = Folder & BackSlash
End If
' Retrieve extension of file name.
Ext = StrReverse(Split(StrReverse(Address), Dot)(0))
' Build full path for downloaded file.
Path = Folder & CStr(Id) & Dot & Ext
If DownloadFile(Address, Path) = NoError Then
Result = Path
End If
End If
UrlContent = Result
End Function
Full code, documentation, and a demo can be found in my project VBA.PictureUrl .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.