Dear Friend,
I am using a VB6 to access crviewer (crystal report 8.5) to view my report. Below are my sub codings which the recordset and connection of ADO is declare in global. The problem I face now is that when I retrieve the record from the database and transfer to crviewer database. The crviewer display blank but there are records transfer to crviewer. I discover that crviewer needs to stop a moment to capture the records in order to display. So, if you check on the fourth last line. I insert "Msgbox" in order for the program to temporary stop in order for crviewer to capture. The issue here is the user has to click off the msgbox in order to resume the program.
Any ideas on how to display the records without stopping the program or has my coding seemed to going wrong somewhere? I appreciated any help. Thanks..
Dim reportBS As New RptBalanceheet
Dim total_i, total_ii As Double
Dim REF, PAYMENTTERM, TOTAL_STR, txtd As String
Dim CompName, RegNo, Add1, Add2, Add3, Add4, Poscode, Tel, Fax, Email, Web As String
rst.Open "Select * from main.company where id='" & db & "' ", cnn, adOpenForwardOnly, adLockBatchOptimistic
If rst.RecordCount > 0 Then
CompName = rst!Name
RegNo = rst!RegNo
Add1 = rst!Add1
Add2 = rst!Add2
Add3 = rst!Add3
Add4 = rst!Add4
Poscode = rst!Poscode
Tel = rst!telr
Fax = rst!telf
Email = rst!Email
Web = rst!Web
End If
rst.Close
rst.Open (sql_cmd), cnn, adOpenForwardOnly, adLockBatchOptimistic
reportBS.DAtabase.SetDataSource rst
If rst.RecordCount > 0 Then
CRViewer1.ReportSource = reportBS
reportBS.ParameterFields.GetItemByName("compname".AddCurrentValue CompName
reportBS.ParameterFields.GetItemByName("regno".AddCurrentValue RegNo
reportBS.ParameterFields.GetItemByName("add1".AddCurrentValue Add1
reportBS.ParameterFields.GetItemByName("add2".AddCurrentValue Add2
reportBS.ParameterFields.GetItemByName("add3".AddCurrentValue Add3
reportBS.ParameterFields.GetItemByName("add4".AddCurrentValue Add4
reportBS.ParameterFields.GetItemByName("poscode".AddCurrentValue Poscode
reportBS.ParameterFields.GetItemByName("tel".AddCurrentValue Tel
reportBS.ParameterFields.GetItemByName("fax".AddCurrentValue Fax
reportBS.ParameterFields.GetItemByName("email".AddCurrentValue Email
reportBS.ParameterFields.GetItemByName("web".AddCurrentValue Web
reportBS.ParameterFields.GetItemByName("trialbalance".AddCurrentValue end_date
Screen.MousePointer = vbDefault
If printer_setup Then
reportBS.PrinterSetup Me.hwnd
printer_setup = False
End If
CRViewer1.ViewReport
MsgBox ("Auto Adjust"
CRViewer1.Zoom 75
End If
rst.Close
I am using a VB6 to access crviewer (crystal report 8.5) to view my report. Below are my sub codings which the recordset and connection of ADO is declare in global. The problem I face now is that when I retrieve the record from the database and transfer to crviewer database. The crviewer display blank but there are records transfer to crviewer. I discover that crviewer needs to stop a moment to capture the records in order to display. So, if you check on the fourth last line. I insert "Msgbox" in order for the program to temporary stop in order for crviewer to capture. The issue here is the user has to click off the msgbox in order to resume the program.
Any ideas on how to display the records without stopping the program or has my coding seemed to going wrong somewhere? I appreciated any help. Thanks..
Dim reportBS As New RptBalanceheet
Dim total_i, total_ii As Double
Dim REF, PAYMENTTERM, TOTAL_STR, txtd As String
Dim CompName, RegNo, Add1, Add2, Add3, Add4, Poscode, Tel, Fax, Email, Web As String
rst.Open "Select * from main.company where id='" & db & "' ", cnn, adOpenForwardOnly, adLockBatchOptimistic
If rst.RecordCount > 0 Then
CompName = rst!Name
RegNo = rst!RegNo
Add1 = rst!Add1
Add2 = rst!Add2
Add3 = rst!Add3
Add4 = rst!Add4
Poscode = rst!Poscode
Tel = rst!telr
Fax = rst!telf
Email = rst!Email
Web = rst!Web
End If
rst.Close
rst.Open (sql_cmd), cnn, adOpenForwardOnly, adLockBatchOptimistic
reportBS.DAtabase.SetDataSource rst
If rst.RecordCount > 0 Then
CRViewer1.ReportSource = reportBS
reportBS.ParameterFields.GetItemByName("compname".AddCurrentValue CompName
reportBS.ParameterFields.GetItemByName("regno".AddCurrentValue RegNo
reportBS.ParameterFields.GetItemByName("add1".AddCurrentValue Add1
reportBS.ParameterFields.GetItemByName("add2".AddCurrentValue Add2
reportBS.ParameterFields.GetItemByName("add3".AddCurrentValue Add3
reportBS.ParameterFields.GetItemByName("add4".AddCurrentValue Add4
reportBS.ParameterFields.GetItemByName("poscode".AddCurrentValue Poscode
reportBS.ParameterFields.GetItemByName("tel".AddCurrentValue Tel
reportBS.ParameterFields.GetItemByName("fax".AddCurrentValue Fax
reportBS.ParameterFields.GetItemByName("email".AddCurrentValue Email
reportBS.ParameterFields.GetItemByName("web".AddCurrentValue Web
reportBS.ParameterFields.GetItemByName("trialbalance".AddCurrentValue end_date
Screen.MousePointer = vbDefault
If printer_setup Then
reportBS.PrinterSetup Me.hwnd
printer_setup = False
End If
CRViewer1.ViewReport
MsgBox ("Auto Adjust"
CRViewer1.Zoom 75
End If
rst.Close