PDA

View Full Version : EXTERNAL CRYSTAL XI REPORT IN VB6



jk
یک شنبه 26 آذر 1385, 09:43 صبح
1) You must enable the "Crystal ActiveX Report Viewer Library 11.0" in the CONTROLS tab of PROJECT - COMPONENTS. A new object will appear in the VB6 TOOLBOX section (the REPORT VIEWER ocx).

2) Create a new form named "FRMCRYSTAL" (frmCrystal.frm) and add the Crystal object into it. The report viewer window will appear inside your form. Put the following lines in its LOAD event:

CRViewer1.Top = 0
CRViewer1.Left = 0
CRViewer1.Height = ScaleHeight
CRViewer1.Width = ScaleWidth

Set its "VISIBLE" property to FALSE and close the form.



2) To open and display an external Crystal XI report, you may use these lines in any place of your program:
I'll divide the task in 4:

2.1) point and open the report;
2.2) change the report parameters;
2.3) change the report SQL query; and
2.4) view the report.


2.1) Let's open the external file.The second parameter ("1") means NO-EXCLUSIVE open or TEMP-COPY open.
If you change for zero (EXCLUSIVE), the report will open just once per session.

Dim MyApp As New CRAXDRT.Application
Dim MyRpt As New CRAXDRT.Report

Set MyRpt = MyApp.OpenReport("c:\windows\sample.rpt", 1)



2.2) Let's change some parameters. Interesting to note the FORMULAFIELD syntax, where I can name my text-fields instead to utilize their indexes (easier to work on than the Business Solution's Crystal manual). Obviously, the name between parenteses must reflect the exact formula/text/field name. In that example, the formulas are STRING type.

MyRpt.ReportTitle = "That's my Title!"

MyRpt.FormulaFields.GetItemByName("InitialDate").Text = "'Initial Day: " & dr1(0).Value & "' "
MyRpt.FormulaFields.GetItemByName("FinalDate").Text = "'Final Day: " & dr1(1).Value & "' "




2.3) Change the report SQL query...

x = 100 : y = 1000
MyRpt.SQLQueryString = "select * from dropouts where InitialIssue <= " & x & " and FinalIssue >= " & y




2.4) Finally, log on your server and database. Since your report already exist and has the appropriated fields and layout, you must use the same database and login info present in the report. In my example, you must change the names for your correct ones.

MyRpt.Database.Tables(1).SetLogOnInfo "<server>", "<database>", "<login>", "<password>"
MyRpt.Database.Verify 'required!!!


' And voil&#225; !!! Show the report!!!

frmCrystal.CRViewer1.ReportSource = MyRpt
frmCrystal.Show
frmCrystal.CRViewer1.ViewReport


' Clear memo...

Set MyRpt = Nothing
Set MyApp = Nothing

reza_rad
یک شنبه 26 آذر 1385, 10:01 صبح
لینک منبع:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=67374&lngWId=1

ممنون میشم مطالبی رو که می گذارید حتما با ذکر منبع باشه.
با سپاس فراوان

شاپرک
شنبه 03 آذر 1386, 12:38 عصر
http://barnamenevis.org/forum/showthread.php?t=69701&highlight=Crystal+Report+VB6

عزیزم کریستان ریپورت 11 با vb6 کار نمی کنه تو باید حداکثر از ورژن 10 استفاده کنی
حداکثر ورژنی که تو VB6 کار میکنه چنده ؟

شاپرک
یک شنبه 04 آذر 1386, 10:21 صبح
کسی جواب این سوال رو نمیدونه ؟ لطفا جواب بدید ...

sm
یک شنبه 04 آذر 1386, 12:52 عصر
حداکثرش ورژن 9 هست.

موفق باشید

مسعود منصوری
شنبه 17 آذر 1386, 12:53 عصر
امکان استفاده کریستال 10 داخل VB هست . البته 11و12 رو نمیدونم .

vbhamed
چهارشنبه 05 دی 1386, 10:41 صبح
سلام
من Crystal Report XI 11 رو توی وی بی 6 تست کردم جواب داد