Printing hyperlinked Word doc automatically with an Access report.

D

David

Hello, hope someone can help. I have a request to print word .doc check
lists with selected records in Access for surgery procedure cards. I
have hyperlinked the word doc's to a field in each record, but do not know
how to write the code to open the word doc and print it. I assume this code
should be put in the list box print button. As you can see, I have two
different reports that go out; one (or more) to Surgery, and one (or more) to
SPD (Sterile Processing).
Thanks for any help given.
--
David

Private Sub cmdPrtRpt_Click()
On Error GoTo Err_cmdPrtRpt_Click

Dim Q As QueryDef, DB As Database
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant

' Build a list of the selections.
Set ctl = Me![List0]

For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = Chr(34) & ctl.ItemData(Itm) & Chr(34)
Else
Criteria = Criteria & "," & Chr(34) & ctl.ItemData(Itm) _
& Chr(34)
End If
Next Itm
If Len(Criteria) = 0 Then
Itm = MsgBox("You Must Select at least One Procedure in the" & _
" List Box!", vbExclamation, "No Selection Made:")
Exit Sub
End If

Set DB = CurrentDb()
Set Q = DB.QueryDefs("qrySelProcCard")

Q.SQL = "SELECT [qryProcCard].* FROM qryProcCard Where
qryProcCard.LstBxAutoNbr In (" & Criteria & ");"
Q.Close

Dim stDocName As String

If cboCopies = 1 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""


ElseIf cboCopies = 2 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal

ElseIf cboCopies = 3 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
ElseIf cboCopies = 4 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
ElseIf cboCopies = 5 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
ElseIf cboCopies = 6 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
ElseIf cboCopies = 7 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
ElseIf cboCopies = 8 Then
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardPrnt"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
stDocName = ""
stDocName = "rptProcCardSpdOnlyPrtToSpd"
DoCmd.OpenReport stDocName, acNormal
End If

DoCmd.Close acForm, "frmSelProcCard", acSaveNo

DoCmd.OpenForm "frmSelProcCard", acNormal, "", "", acEdit, acNormal

Exit_cmdPrtRpt_Click:
Exit Sub

Err_cmdPrtRpt_Click:
MsgBox Err.Description
Resume Exit_cmdPrtRpt_Click
End Sub
 

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

Similar Threads


Top