Attachments Will Not Show in SubForm

hhzyousafi

Registered User.
Local time
Today, 16:16
Joined
Nov 18, 2013
Messages
74
I have a table called "tblTasks" and the table allows users to attach files to a task they wish to assign to a resource in their respective department. I have based a query on this table that returns the tasks associated with a given resource; however when the resource tries to view the attachment via a Subform - the Subform is based on the query - the attachment field does not yield any understandable results. The query is correct because all of the other data for the tasks show up perfectly; however the attachment, for some reason, is missing. Can someone help!?
 
Your subform needs to be a single or continuous form, not a datasheet
 
Hi CJ,

Thank you for the quick response. I have tried that and whilst I can now see the attachment icon I am still unable to actually open the attachment. Am I missing some easy setting here?

Regards,

Zohair Yousafi
 
Sorry - I don't know, I don't use attachments - someone else may have a suggestion.

The way I do it is to not store attachments in the db at all (although better in later versions of Access, they still bloat the db), but in a specified directory, and I store the filename in a text field in the db.

So if I want to open a file I set the double click event for the filename textbox (or I might use a button depending on requirements) and run the following code

Code:
Dim W as Long
W = ShellExecute(0, "Open", """" & myPath & me.Filename & """", vbNullString, vbNullString, 1)

myPath is the path to the specified directory (including a final '\') and me.filename is the name of the file you want to open.

Note you also need to put the following in to a standard module

Code:
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
 

Users who are viewing this thread

Back
Top Bottom