Colin,
I'm making progress with report, but I'm not quite there yet and can't get the report to display. Two sections of code below: the first is the opening code from frmPrintOptions where the user selects the "Preview" option. The second is the report's code module, where I've attempted to adapt your code to my report, I even captured your "print command button". Anyway, all I get is the report title bar located at 0,0, as shown in the screenshot.
Code:
Private Sub cmdPreview_Click()
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
'
'=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Me.Visible = False
On Error GoTo Err_Handler
'hide form & open report in report view
DoCmd.Minimize
DoCmd.OpenReport "rptDirectory", acViewReport, , , acDialog, "RV"
DoCmd.Close acForm, "frmprintoptions"
Exit_Handler:
Exit Sub
Err_Handler:
strProc = "cmdReportView_Click"
MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.description
Resume Exit_Handler
End Sub
Code:
Option Compare Database
Option Explicit
Dim strAppendage As String
Dim strProc As String
Private Sub Report_Open(Cancel As Integer)
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' strRptSort is a global variable that is set by frmRegistry and frmPrintOptions
' depending on conditions chosen by the user. The OPEN code here simply adjusts
' the report title section in keeping with and the setting of the sort order.
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
On Error GoTo Err_Handler
Select Case Me.OpenArgs
Case "RV" 'acViewReport
DoCmd.Restore
Case Else 'acViewPreview
DoCmd.Maximize
End Select
Me.lblHeader.Caption = strRptTitle
Select Case strRptSort
Case "lblLastName"
strAppendage = "Last Name"
Me.OrderBy = "LastName"
Case "lblFirstName"
strAppendage = "First Name"
Me.OrderBy = "FirstName"
Case "lblUnit"
strAppendage = "Apartment numbers"
Me.OrderBy = "Unit"
Case "lblExt"
strAppendage = "Telephone Extensions"
Case "lblCell"
strAppendage = "Cell numbers"
Me.OrderBy = "Cell"
Case "lblLandLine"
strAppendage = "Landline numbers"
Me.OrderBy = "Landline"
Case "lblEMA"
strAppendage = "Email Addresses"
Me.OrderBy = "EMA"
End Select
Me.RecordSource = strRptRecSrc
Me.Filter = strRptFilter
Me.FilterOn = True
Me.OrderByOn = True
Me.lblSortedBy.Caption = "Listing Sorted by " & strAppendage
Exit_Handler:
Exit Sub
Err_Handler:
strProc = "Report_Open"
MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.description
Resume Exit_Handler
End Sub
Private Sub Report_Load()
On Error GoTo Err_Handler
'Show & maximize ribbon
ShowRibbon
If IsRibbonMinimized = True Then ToggleRibbonState
ShowRibbon
Exit_Handler:
Exit Sub
Err_Handler:
strProc = "Report_Load"
MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.description
Resume Exit_Handler
End Sub
Private Sub cmdPrint_Click()
On Error GoTo Err_Handler
Me.lblHeader.Width = 11670 'Restore header width to 8.1042 inches
DoCmd.PrintOut
Exit_Handler:
Exit Sub
Err_Handler:
strProc = "cmdPrint_Click"
If Err <> 2501 Then 'err 2501 - user cancelled printing
MsgBox "Error " & Err.Number & " in " & strProc & " procedure : " & Err.description
End If
Resume Exit_Handler
End Sub
What am I missing?