I have a an Object OLE field in a table where users can insert Excel sheets, Word Docs, Pdfs etc.
I need to create a button on a formulaire that allows the user to browse for, select and attach the file. The file must appear as an icon that can be double clicked on to be opened. The file should be stocked in the DB.
I can make a dialog box appear and browse for the file and copy the path into the field using this code:
Expand|Select|Wrap|Line Numbers
- Private Sub AttachButton_Click()
- Dim varFile As Variant
- With Application.FileDialog(msoFileDialogFilePicker)
- With .Filters
- .Clear
- End With
- .AllowMultiSelect = False
- .InitialFileName = vbNullString
- .InitialView = msoFileDialogViewDetails
- If .Show = True Then
- For Each varFile In .SelectedItems
- Me![File] = varFile
- Next
- Else
- MsgBox "No file attached ! "
- End If
- End With
- End Sub
(see http://bytes.com/topic/access/answer...ord-attachment)
But it needs to be an object sitting there, not just the path to the file.
Any help or alternative suggestions would be appreciated.
e