Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21100

Passing recordset to a function - VB6

$
0
0
I want to have a datagrid printed. I have used the following code.


Private Declare Function GetDefaultPrinter Lib "winspool.drv" Alias "GetDefaultPrinterA" (ByVal sPrinterName As String, lPrinterNameBufferSize As Long) As Long
Dim PRNDEF As Printer

Function PrintRecordSet(rs As Recordset, PRN As Printer)
----
End Function

Private Sub Form_Load()
Dim sLen As Long, DefPrinter As String, iPrn As Printer, hResult As Long
DefPrinter = Space$(255)
sLen = 255
hResult = GetDefaultPrinter(ByVal DefPrinter, sLen)
If hResult <> 0 Then DefPrinter = Left(DefPrinter, sLen - 1)
For Each iPrn In Printers
If iPrn.DeviceName = DefPrinter Then Set PRNDEF = iPrn
Next
End Sub

Private Sub Command1_Click()
Call PrintRecordSet(Adodc1.Recordset, PRNDEF)
End Sub

I get an error "Type mismatch" in the CALL function.

Any help shall be greatly appreciated.

Viewing all articles
Browse latest Browse all 21100

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>