Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Query returns more than one hyperlink report to print.  How can I print all the ones it finds?

Posted on 2011-02-16
5
Medium Priority
?
216 Views
Last Modified: 2012-05-11
I have one or more pdf documents linked to a form, but my code will only print one of the documents, not all.  What do I need in order to print all the documents the query finds on this command button?  

Private Sub prtndt_Click()
On Error GoTo Err_prtndt_Click

Dim qd As Long

qd = DCount("*", "qryLinkedDocuments", "det_id=" & Me!ID)
If qd > 0 Then
  
 strfile = DLookup("ImagePath", "qrylinkeddocuments", "det_id=" & Me!ID)
 ShellExecute Me.hwnd, "open", strfile, Chr$(0), strPath, 3
 
Else

MsgBox "There are no NDTs to print.", vbOKOnly

End If

Exit_prtndt_Click:
    Exit Sub

Err_prtndt_Click:
    MsgBox Err.Description
      Resume Exit_prtndt_Click
    
End Sub

Open in new window

0
Comment
Question by:bwestly
  • 3
  • 2
5 Comments
 
LVL 13

Accepted Solution

by:
Surone1 earned 2000 total points
ID: 34912737
set rs = currentdb.openracordset('select * from qrylinkeddocuments where det_id= " & Me!ID)
do while not rs.eof
strfile = rs.fields("imagepath").value
ShellExecute Me.hwnd, "open", strfile, Chr$(0), strPath, 3
rs.movenext
loop
0
 
LVL 13

Expert Comment

by:Surone1
ID: 34912751
set rs = currentdb.openrecordset('select * from qrylinkeddocuments where det_id= " & Me!ID)
0
 
LVL 13

Expert Comment

by:Surone1
ID: 34912755
set rs = currentdb.openrecordset("select * from qrylinkeddocuments where det_id= " & Me!ID)
0
 

Author Comment

by:bwestly
ID: 35034015
Sorry, Surone1

I didn't get any emails about your answer.  Don't know where they went.  I will check this out tomorrow and let you know if it works.  

Thanks.
0
 

Author Closing Comment

by:bwestly
ID: 35833954
Thank you for the great information.  I'm so sorry it took so long to get back into the problem.  I can print multiple PDFs with no problem now.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question