Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 & Access 2000 reports

Status
Not open for further replies.

christian7

Programmer
Feb 16, 2000
2
US
Has anyone tried using Access2000 as a automation server from vb6 as far as reports are concerned? Having trouble getting the print preview to work (it will print fine but I get an empty Access windows if I try preview).<br>
<br>
The code I used works with Vb5 and Access 97. I don't get errors and the report actually gets loaded (I put a msgbox in the report_open sub). It's there, just not showing.<br>
<br>
Thanks,<br>
Christian
 
Can you paste some code here?<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
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>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top