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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small trouble in CrViewer in VB

Status
Not open for further replies.

Dino1975

Programmer
Jan 24, 2002
6
MY
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

 
Hi,

There may be a better way of printing your reports instead of using parameter fields...but I'm not sure. Then again, I also don't know what you are trying to do!

What you could do instead of using a message box is a loop with a doevents in it like this:

for x = 1 to 30000
doevents
next

This will cause a pause to occur in the program and forces VB to complete any open events.

Good Luck!
 
Dear Laki,

I created the parameter to display the company header on a report. The reason why is I am cutting down the Server and Client Processing Power by avoiding executing one heavy SQL command to retrive records from multi table.

And thanks... it works like a charm. There is another issue I like to ask for your opinion. In my report, I display customer info on the report header and customer order sales in the details. I like to generate a report that has each customer on a new page. How do I do that?

I thought of writing a code in REport header's format section on "New Page After". Tell me whether I am on the right track. Thanks.
 
I like to learn more about variable in Crystal report and how to use it. I can't afford to purchase a book. Internet is my only options. Could anyone pleease direct me a website that educate Crystal report learner on variables.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top