Saturday, February 25, 2012

preview current data from vb form to Crystal Report

hi...
i have a question here and need u'r help.

i have sales data in my vb form, and i want to preview or print it using crystal report. my problem is, crystal report print all sale data in my table sales. all sale data have their own resit number. how can i print only data with resit number that i key in, in my vb form?

hope u can help me...
TQTry the example attached to my post|||dear joe911..

thank u...but i can't open the attachment. can u tell me how i can open tha file that u given,..|||it is compressed with wiarar: http://www.rarlab.com
by the way this example apllies to ver 9.2
here is another one compressed using winzip|||thanz joe..|||i've try the code but i still have a problem. crystal report still preview all the data in sales table.
can anyone help me...|||u sure that u did like the example?
plz upload ur project|||Dear joe...

here is my coding...i use sql server as my database. Hope u can tell me what is wrong with my coding...

Dim Appl As New CRAXDRT.Application
Dim Report As New CRAXDRT.Report
Dim adoSql As ADODB.Connection

Private Sub Form_Load()
Dim strSQLStatement As String
Dim rsReport As ADODB.Recordset
strConnection = " Provider=sqloledb;data source=PRE;User ID=sa; initial catalog=PSM"
Set adoSql = New ADODB.Connection
Set rsReport = New ADODB.Recordset

adoSql.Open strConnection
strSQLStatement = "SELECT * FROM TSales" & _
" WHERE day ='" + Form5.DCday.Text + "'" & _
" AND month ='" + Form5.DCmonth.Text + "'" & _
" AND year ='" + Form5.txtyear.Text + "'" & _
" AND member_id= '" + Form5.txtmember.Text + "'"

Set rsReport = adoSql.Execute(strSQLStatement)
If rsReport.EOF Then
MsgBox " No Record Found", vbCritical, "Status"
Else
Set Report = Appl.OpenReport("D:\PSM ODBC\Laporan\Report2.rpt")
Screen.MousePointer = vbHourglass
CRViewer91.ReportSource = Report
CRViewer91.Zoom 70
CRViewer91.ViewReport
Screen.MousePointer = vbDefault

End If
adoSql.Close
End Sub|||ur code looks fine, but the problem isn't in the code, if u using external rpt files u have to UNCHECK this option: file>>save data with report , like this image:

http://yoyo911.spymac.net/images/Crystal_Problem.JPG

by the way using designer(my example) is better, coz no one can edit the design of the reports as there is no external .rpt files.

i hope this help u.
bye|||hi joe...
i'm sorry again but it't not work.
what do you mean external.rpt?|||what i meant by external.rpt is the report file,
i use the designer, it is something like the data report (means no rpt file needed, the report will be included in the .rpt file)

to use the deigner, just select project>>add crystal reports 9>>from existing report>>browse the report.

about ur problem : r u sure that u removed the true sign from the option Save data with report?

and try to use the way explained above.|||yup...i've uncheck Save data with report just like u said.

i'll try u'r to use the designer. hope it will works...

TQ again|||hi,
just figured u forgot this line:

CRViewer91.ReportSource = Report
Report.Database.SetDataSource rsReport, 3, 1|||i have try that line but have an error.
i though because i use sql server.
the example that u give to me use access as database.

what is 3, 1 mean?

Report.Database.SetDataSource rsReport, 3, 1|||sorry, i forgot that!

The syntax for SetDataSource is as follows:
[form] Object.SetDataSource data, DataTag, tableIndex

i think this method applies only for the designer as i didn't try it b4 with .rpt file,
try using this way and see what happens|||thank...i will try that code.
i really hope it works.
my due date is very near to present my system.|||hi...i still can't priview the report just like i want. it has an error. can u tell my how to solve this problem using data report in VB?|||Dear,
We r working with crystal reports 9 designer not Data Report!

would u plz send me ur project to this mail: joe911_2003@.yahoo.com|||hai joe...
i've settle my problem.
thank u for your attention and help.|||happy u passed ur problen.
would u plz tell me what was that?
thnx bye|||hi joe..

actually i'm not solve my problem the way that i want. tomorrow i must present my system so i don't have time to try solve my problem the way that i want. cause i don't know what is wrong...so i just use group method in crystal report.
the problem when i use this method is, the report will show all receipt num and i must search the receipt num that i want. when i klik that receipt number, it will display subreport that contain all the information about the receipt num. that the way that i see right now..don't know what the judge will say about that in my presentation tomorrow...

by the way thank cause your help and idea...hope i can try to solve that problem after my presentaion.

No comments:

Post a Comment