Printing attachments with Reports

S

Steve Wood

Hi all, Thanks in advance for any assistance you can give;

I have a report which contains an attachment field, what I need is for any
attachments linked to the report to be printed additionaly to the report when
the user clicks a print report button - any ideas?
 
M

Mark Andrews

In general I would guess you need to:
- save the attachment(s) to disk
- use appropriate automation to open/print attachment(s)


Here's some code I use to save attachments:
'Open recordset of attachments, save each one to disk and assign to
attachments() array
For iii = 1 To 9
Attachments(iii) = ""
Next iii
filepath = CurrentDBDir() & "Attachments999\"
If Len(Dir(filepath, vbDirectory)) = 0 Then
MkDir filepath
End If
iii = 1
Set RSAttachments = rs.Fields("Attachments").Value
While Not RSAttachments.EOF
If (FileExists(filepath &
RSAttachments.Fields("FileName").Value)) Then
Kill filepath & RSAttachments.Fields("FileName").Value
End If
RSAttachments.Fields("FileData").SaveToFile filepath
Attachments(iii) = filepath &
RSAttachments.Fields("FileName").Value
iii = iii + 1
RSAttachments.MoveNext
Wend
RSAttachments.Close


Function CurrentDBDir() As String

Dim strDB As String, strCurrentDir As String

strDB = CurrentDb.Name
strCurrentDir = Left(strDB, Len(strDB) - Len(Dir(strDB)))

CurrentDBDir = strCurrentDir
End Function


It saves all the attachments (well, up to 9) that are in the attachments
field in directory attachments999 and populates the attachments() array with
filenames to be used.

Then you need to write the code to do the automation open/print of the
attachments.

I've done a bit of automation code if you require assistance in your
project.

Hope this makes sense and helps you get started,
Doesn't sound like an easy task,
Mark Andrews
RPT Software
http://www.rptsoftware.com
http://www.donationmanagementsoftware.com
 
S

Steve Wood

Excellent starting point Mark many thanks for that,

I guess I need to explain my project in more detail as this could help a lot
of people out there:

I am writting an access database to share information and collaberation
accross UK and US domains through SharePoint.

The reports that are contained need to be printed as hard copies in case of
loss of network or systems during a crucial timeframe.

Attachments are required as evidence and walkthroughs for each party accross
the domains.

The attachments will have to be printable with the reports to ensure each
party has all information they need as a backup copy.

As the backend of the database is stored on SharePoint the reports should be
available by there URL.

So is it possible to use the stored URL location as a reference when calling
the print option?
 
M

Mark Andrews

Sorry I haven't used Access with Sharepoint much. I thought in Access a
Sharepoint list/document library is just really a linked table.

So reports in Access work as normal, you open the access db and run the
report and print it, or you use code so when a user clicks a button the
report prints or something of that nature. So the access database itself
would exist outside of Sharepoint, sitting on the users C: drive.
This would mean there is no URL to the reports.

Perhaps if looking for a way to print out documents attached to a document
library or attachments in a list you should look at third party sharepoint
tools? Maybe there is a way, not sure?

I don't think I'm going to be any more help on this topic,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top