
Nguyên bản được gửi bởi
cham3cham
bình thường là .ShowPreview(); thì bạn thay bằng .Print(); là ok.
Tớ đã thử nhiểu cách rồi nhưng bị lỗi, ko biết xử lý lỗi này ra sao
Code:
Code:
Private Sub Auto_Print()
Dim rpt As New rptpos
Dim path As String = "E:\Com_RS232_SQL\Report\rptHoaDon.rpt"
rpt.Load(path) 'your report file and path
rpt.SetParameterValue("hoten", Me.txtHoten.Text) 'Lỗi dòng này
rpt.SetParameterValue("masv", Me.txtMaSV.Text)
rpt.SetParameterValue("noidung", Me.txtnoidung.Text)
rpt.SetParameterValue("sotien", Me.txtSotien.Text)
'if you normally setlogon and paramaters and stuff do that here
rpt.PrintOptions.PrinterName = "\\10.1.91.245\HP LaserJet P2015 Series PCL 5e" 'your windows printer name
rpt.PrintToPrinter(1, False, 0, 0)
End Sub
Sorry vì cái này tớ viết = vbnet, thông báo lỗi là: Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
Bạn nào có kinh nghiệm chỉ bảo giúp