I have a form which is used to create reports. if i don't filter the records on the form using a textbox to use keyword search. the report button will happily output a report of all the records in Word,PDF and excel. however, if i filter the records and the records that have been filtered exceed 495 records i cannot get a report to be outputted. any thoughts please.
code for full report:
Private Sub cmdPreviewReport_Click()
On Error GoTo cmdPreviewReport_Click_Err
Dim oApp As Object
Dim oDoc As Object
Dim sTmpltName As String
'Dim AppWord As Application
'Dim Doc As Documents
'Dim NameOfDocument
' john's original code:
'DoCmd.OutputTo acOutputReport, "rptBuildings", "PDFFormat(*.pdf)", "", True, "", 0, acExportQualityPrint
' nic meddling from here
'NameOfDocument = "arse"
'case statement here for pdf word or excel
Select Case frmReportFormat.Value
Case 1
DoCmd.OutputTo acOutputReport, "rptBuildings", "PDFFormat(*.pdf)", "", True, "", 0, acExportQualityPrint
Case 2
DoCmd.OutputTo acOutputReport, "rptBuildings", "RichTextFormat(*.rtf)", "", True, "", 0, acExportQualityPrint
Case Else
DoCmd.OutputTo acOutputReport, "rptBuildings", "Excel97-Excel2003Workbook(*.xls)", "", True, "", 0, acExportQualityPrint
End Select
' to here
cmdPreviewReport_Click_Exit:
Exit Sub
cmdPreviewReport_Click_Err:
'MsgBox Error$
'Resume cmdPreviewReport_Click_Exit
End Sub
Code for filtered report:
Private Sub CmdViewSelection_Click()
On Error GoTo CmdViewSelection_Click_Err
Dim strWhere As String
Dim ctl As Control
Dim varItem As Variant
'make sure a selection has been made
If Me.SearchResults_Multi.ItemsSelected.Count = 0 Then
MsgBox "At Least 1 Record Must Be Selected!!", vbInformation, "Record Selection Required"
Exit Sub
End If
'add selected values to string
Set ctl = Me.SearchResults_Multi
For Each varItem In ctl.ItemsSelected
strWhere = strWhere & ctl.ItemData(varItem) & ","
'Use this line if your value is text
'strWhere = strWhere & "'" & ctl.ItemData(varItem) & "',"
Next varItem
'trim trailing comma
strWhere = Left(strWhere, Len(strWhere) - 1)
DoCmd.OpenReport "rptPartBuildings", acViewReport, , "RoomID IN(" & strWhere & ")"
Select Case frmReportFormat.Value
Case 1
DoCmd.OutputTo acOutputReport, "rptPartBuildings", "PDFFormat(*.pdf)", "", True, "", 0, acExportQualityPrint
Case 2
DoCmd.OutputTo acOutputReport, "rptPartBuildings", "RichTextFormat(*.rtf)", "", True, "", 0, acExportQualityPrint
Case Else
DoCmd.OutputTo acOutputReport, "rptPartBuildings", "Excel97-Excel2003Workbook(*.xls)", "", True, "", 0, acExportQualityPrint
End Select
'open the report, restricted to the selected items
'DoCmd.OpenReport "rptBuildings", acPreview, , "RoomID IN(" & strWhere & ")"
'DoCmd.OpenReport "rptPartBuildings", acViewReport, , "RoomID IN(" & strWhere & ")"
'DoCmd.OutputTo acOutputReport, "rptBuildings", "PDFFormat(*.pdf)", "", True, "", 0, acExportQualityPrint
'DoCmd.SelectObject acForm, "frmBuildingSearch"
'DoCmd.Close
DoCmd.SelectObject acReport, "rptPartBuildings"
DoCmd.Close
CmdViewSelection_Click_Exit:
Exit Sub
CmdViewSelection_Click_Err:
End Sub