Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Gentlemen, i have a problem in my Crystal Report, I'm really appreciate if anyone can help me,

my trouble is

1. message box of type mismatch always shown when i click print button, but the data which i want to print is right that shown in my crystal report.

What i did recently:
1. i design my crystal report in vb 6.0 by add crystal report in my project
2. i had make the data type in my crystal report design same as data type in my database
3. recently i use this technique to show my data in crystal report

VB
Private Sub cmdPrint_Click()
Call Buka
Dim pil1 As New ADODB.Recordset
Dim sql1, pilihan1, strdata As String
Dim a1, b1 As Date
Dim cetak As New PageSet.PrinterControl
a1 = tglawal.Value
b1 = tglakhir.Value
pilihan1 = cbpilihan.Text
Adodc1.ConnectionString = Conn
Set cryApp = New CRAXDRT.Application
'Set rptApp = cryApp.OpenReport("C:\Documents and Settings\NKP\Desktop\crush it\Report\rptpinjam.rpt")
Select Case pilihan1
                Case "All"
                                sql1 = "select m.no_faktur,m.pemohon,m.peminjam, b.nama ,d.jumlah_mnt,d.jumlah_app,d.tgl_pnjm,d.tgl_kmbl,d.approve,d.keterangan from dtl_pinjam d inner join dtl_barang b on d.id_barang = b.id_barang inner join mspeminjaman m on d.no_faktur = m.no_faktur order by d.no_faktur asc;"
                                'sql1 = "select * from dtl_pinjam order by no_faktur asc;"
                                'Set pil1 = Conn.Execute(sql1)
                                
                Case "Tanggal"
                                sql1 = "Call viewpnjmbytgl('" & a1 & "','" & b1 & "')"
                                'Set pil1 = Conn.Execute(sql1)
                                
                Case "Belum disetujui"
                                sql1 = "Call viewpinjamblmck"
                                'Set pil1 = Conn.Execute(sql1)
                                
                Case "Disetujui"
                                sql1 = "Call viewpinjambyapp"
                                'Set pil1 = Conn.Execute(sql1)
                                
                Case "Ditolak"
                                sql1 = "Call viewpinjambyrjct"
                                'Set pil1 = Conn.Execute(sql1)
                                
End Select
                Adodc1.RecordSource = sql1
                Adodc1.Refresh
                CRpeminjaman.Database.SetDataSource Adodc1.Recordset
                PrintPreview.CRViewer1.ReportSource = CRpeminjaman
                PrintPreview.CRViewer1.ViewReport
                PrintPreview.CRViewer1.Zoom 100
                PrintPreview.Show
                PrintPreview.WindowState = 2
             
End Sub


what i still confuse:
1. what must i do to trace that type mismatch error? i had check my CR design, data type in my database, my query that run well.
2. is Date format is really impact to this? my CR design is DATETIME, n my db design is DATETIME too such as dd/mm/yyyy h:mm:ss
3. is null field is really impact too? some of my field is null.
Posted
Comments
_Damian S_ 6-May-13 1:13am    
Set a breakpoint in your code towards the top of your sub, then run your program. Step through the code one line at a time until you locate the line that is causing the error.
White Magician 6-May-13 2:09am    
Thanks for response Damian, it works until line
PrintPreview.CRViewer1.ReportSource = CRpeminjaman , that the msgbox is shown type mismatch,
how to solve this?
_Damian S_ 6-May-13 2:12am    
Where are you defining CRpeminjaman? I assume it's a crystal report within your system?
White Magician 6-May-13 2:17am    
yes, u right, i add Crystal report in my project by Project -> add Crystal Reports 7
that CR i named CRpeminjaman, i'm really grateful if u can help me :D
_Damian S_ 6-May-13 2:34am    
You should have a crystal report variable, that you assign the value to. eg:

Dim crDoc As CrystalDecisions.CrystalReports.Engine.ReportClass
set crDoc = new CRpeminjaman

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900