I have a form, rptReminders, that is based off a query with a listbox that displays the results of the query. The user can select desired tasks within the list and then click a command button to print the selected tasks with ALL the data from the record.
This DOES work, to a certain degree. It puts the records to the screen so they can be viewed rather than directly to the default printer of the user.
What I need it to do is to PRINT to the printer rather than the screen. I don't know how though.
The code behind the button is:
This DOES work, to a certain degree. It puts the records to the screen so they can be viewed rather than directly to the default printer of the user.
What I need it to do is to PRINT to the printer rather than the screen. I don't know how though.
The code behind the button is:
Code:
Private Sub cmdPrintSelection_Click()
'check to see if there are records selected to print on individual rptTask forms including
'all of the information on the records. If not, display message box saying user has to select
'at least one record to print.
Dim strSQL As String, strvalue As String, varItem As Variant
'Check to see i f the user has select an item from the list
If List21.ItemsSelected.Count = 0 Then
MsgBox ("You Must Select at least one Task to print")
Me.List21.SetFocus
Else
'Create the string which will be used as the criteria of the report
strSQL = "Task_ID = "
'Cycle through items selected and add selected items as part of the string
For Each varItem In Me.List21.ItemsSelected
strSQL = strSQL & Me.List21.ItemData(varItem) & " OR Task_ID = "
Next varItem
Debug.Print strSQL 'see SQL String before
'Trim the string
strSQL = Left$(strSQL, Len(strSQL) - 14)
Debug.Print strSQL 'see SQL string after
'Open the report rptStdHistPALL using the string criteria
DoCmd.OpenReport "rptTaskReminders", acViewPreview, , strSQL
End If
End Sub