DougP,<br>
<br>
Here is the code for VB5. Just change Application.8 to 9 (for Access 2000) or you could use early binding (dim oAccess as access.application) since vb6 seems to agree with this also (then use set oAccess = new access.application). <br>
<br>
Sub PrintOLEReport(rptName As String, toPrinter As Integer, Optional sWhereCondition As String)<br>
Dim oAccess As Object, lHandle As Long, lAccessHwnd As Long<br>
<br>
On Error GoTo ReportError<br>
Screen.MousePointer = vbHourglass<br>
Set oAccess = CreateObject("Access.Application.8")<br>
oAccess.OpenCurrentDatabase App.Path & "\OLEAuto.mdb", False<br>
If IsMissing(sWhereCondition) Then<br>
oAccess.DoCmd.OpenReport rptName, toPrinter<br>
ElseIf Len(sWhereCondition) = 0 Then<br>
oAccess.DoCmd.OpenReport rptName, toPrinter<br>
Else<br>
oAccess.DoCmd.OpenReport rptName, toPrinter, , sWhereCondition<br>
End If<br>
<br>
If toPrinter = acViewPreview Then<br>
oAccess.DoCmd.Maximize 'maximize the report window<br>
lAccessHwnd = oAccess.Application.hWndAccessApp<br>
If IsIconic(lAccessHwnd) Then ShowWindow lAccessHwnd, SW_SHOWNORMAL<br>
ShowWindow lAccessHwnd, SW_SHOWMAXIMIZED<br>
<br>
lHandle = oAccess.Reports(rptName).hwnd<br>
Do While IsWindow(lHandle)<br>
DoEvents<br>
Loop<br>
End If<br>
oAccess.Quit 2 'acQuitSaveNone<br>
Set oAccess = Nothing<br>
GoTo PrintReport_Exit<br>
<br>
Like I said, if I pass the parameter to print, it works. If I pass one to preview, empty window (lights on, nobody home).<br>
Thanks, Christian<br>