Created by : Agus Indra Cahaya Website: http:((cybercatzone.

net

Chat: sonic_error I cybercatzone

Mail: sonicerror@yahoo.comlcybercatzone@yahoo.co.id

Tips and Tricks Crystal Report 8.5

(VB 6.0)

1. Koneksi Database SQl Server 2000

Asumsi Ms. SQL Server 2000 sudah diinstal dan Running (Server: "LOCAL", User: "SA", Password :"") PROSES PADA CRYSTAL REPORT

a. Buka CR 8.5

b. Buat New Report

Welcome to CrysliLl Reports [R]

P' _:2how welcome dialog at startup

C. Masukan database "NorthWind" (database bawaan Ms SQL Server 2000) 1) Pilih jenis koneksi seperti gambar dibawah:

mi Data Explorer ~

rnr.=JCurrentConnectiom rnCiFavorite~ IiIE::!Hislory lBElODBC

IiJ"CJDatabaseFiles EH.!}More Data Sources Data

_8_emove

AddloEa\loritej< I QeletaFal'orit.e I

Qptiom".

Help

CJose

2) Masukan data Server(".", untuk server lokal), UserlD("sa", usah default, Password("", misalnya password kosong), Oatabase("Northwind", karena menggunakan sample bawaan Ms SQL 2000)

3) OK

d. Masukan table "Order Details"

1) Pilih Tabel"Order Details" (Dbo.Order Details) > Add

mi Data Explorer ~

El-e:.JMicrosoft SQL Server ~I

111 Make New Connection

a",

~Northwind_dbo_[Alphab8tic:alli8to ·~Northwind_dbo_[Cat8gor.'r'SaI8slo ·1!l],Northwind_dbo_[Culient Product L ·1!l],Northwind.dbo.[Cmtomer and SUI .Ill] Northwind.dbo.[Order Details Exle

~j'G!l!.'i,.!.m.m"a!

Ii] Northwind.dbo.[OrderSubtotalsl ~ Nnrthwinrlrlhnrnrrlpr~llrul

,!I,dd

BemoY8

AddIDE.:r\lDritej< I Qele~e Fal'orit.e I

Qptiom".

Help

2) Close

CJose

1

Created by : Agus Indra Cahaya Website: http://cybercatzone.net

e. Masukan Field "OrderID"

Chat: sonic_error I cybercatzone

Mail: sonicerror@yahoo.comlcybercatzone@yahoo.co.id

~ Field Explorer (gJ

13--' Database Fields' B"'~ [Order Details]

.... ~ um@'W,mil

.... [J3 ProductlD: Number .... IE! UnitPrice: Currency .. [J3 Quantity: Number 1EOi" Discount: Number .... ;£!; Formula Fields:

IlliI SQL Espression Fields

f. Simpan dengan nama default (Reportl.rpt)

a. b.

~ 1w ~ ",.
...
ActiveX VB Application
Control Wizard
~ ~ ~ ~
ActiveX ncnvex Addin Data Project
Docurnent D] ~ ~ ~

r Don't show ths di-3log in the f.!,!lure

C. Masukan komponen "Crystal Report Viewer" (crviewer.dll) 1) Project> Components atau CTRL + T

Cempenents [8J

Browse".

controls I Designer$1 Ipserteble Objects I

DC:\WINDOWS\system32\tdc,ocx DCdig

Dcic1.0TypeLibrary DCompatUl1.OTypeLibrary DComSnap1.0TypeLibrary

DCrystal Report Control

~.'i@@I'4¥§F· ,liN

D Crystal Select Expert OLE Control module D ctv OLE Control module DDdsSr.apesl.OTypeLibrary

DDHTML Edit Control ForIE5

DEmbeddable Crystal Reports 8.5 Designer Cont

DFIUplControlLibrary ~

~ !>J

r 2_elected Items Only

iCry,ta'Report viewer Control

Location: C:\ ... \\lie .. \ActilleX\liewer\ulliewer.dll

2) OK

3) Tambahkan komponen ke Form

General

----------------------------------

----------------------------------

iii Project1 - Form1 (Form)

~GA .1aiJj 0 _j

P" r- §I ~ jJ!J ;. m)EleJ ~V'-. mJl i@j '1lIll

(~

.. Form1 ~§~

2

Created by: Agus Indra Cahaya Chat: sonic_error I cybercatzone

Website: http://cvbercatzone.net Mail: sonicerror@yahoo.comlcybercatzone@yahoo.co.id

d. Referensikan "Crystal Report Active Runtime Library" (craxdrt.dllJ 1) Project> References

References Project1 ~

prioritY~

~

B_vailableReferenCBS:

Location: C\Program Files\5eagate Sottwere'[Repcrt Designer Compere

Language: Standard

2) OK

e. Buka View Code, tambahkan script berikut : (#awa 1-------------------

Dim vApp As New CRAXDRT.Application Dim vRpt As New CRAXDRT.Report

Dim vServer As String

Dim vDatabase As String

Private Sub Form_Load() vServer = "."

vDatabase = "northwind"

Set vRpt = vApp.OpenReport(App.Path & "\Reportl.rpt") vRpt. DiscardSaved Data

'Yang perlu jadi perhatian!

'[Nama Server],[Nama Database],[User],[Password] vRpt.Database.LogOnServerEx "p2ssql.dll", vServer, vDatabase, "sa", "" vRpt.Database.Tables(l).SetLogOnlnfo vServer, vDatabase, "sa", "" vRpt.Database.Tables(l).Location = vDatabase & ".dbo.Order Details" CRViewer1.ReportSource = vRpt

CRViewer1. View Report

End Sub

(#a kh i r -------------------

f. Simpan 1 folder dengan reportl.rpt

g. Jalankan Keterangan:

Bagian yang berwarna merah merupakan bagian penting untuk menangani error seperti gambar berikut :

Micro!>oft'll!;UaLBas1c

Run-time error '-2147192184 (80047288)':

Server has not yet been.opened.

3

Created by : Agus Indra Cahaya Website: http:((cybercatzone.net

2. Passing Parameter

PROSES PADA CRYSTAL REPORT

a. Tambahkan 1 Parameter

1) Pada Field Exprorer, pilih Parameter Fields

Chat: sonic_error I cybercatzone

Mail: sonicerror@yahoo.comlcybercatzone@yahoo.co.id

I!:!i FIeld Explorer ~

gJ---1I Detebase Fields G---W FormulaFields

, ~JudulF ~.SQLE~pre3sionFields SI?I Ii!III!III!IIiI

;·~Judul

... ~ Running Total Fields ... ~ GrQUp Name Fields 1±l---£SpeciaIFields

2) Buat parameter Judu/

Edit Parameter Field ~

Parameter Field
Neme Judul
P!omptingtext
~aluet}'pe I String il Uptions ---------------

r AIIOf:1 multiple veuee _2el default values

r. QiscretevalueH

r Ran_g8 veluejs] F1 AllQw editing 01 default velues when

r Discrete and Henqe veloes there is more lhen cne value

3) OK

b. Tambahkan 1 Formula

1) Pada Field Exprorer, pilih Formula Fields

mi Field Espterer ~

~···I Detebese Fields El···~ FormulaFields ;·~JuduIF ··~SQLExprenionField*:

Bl?lli!lll!lll!llil

; ~Judul

i Running Total Fields

.oct'

2) Buat Formula Judu/F

Fermula Name rg)

.t::!ame JudulF

3) Isikan nilai defaul / nilai awal, bisa menggunakan rumus atau langsung nilai

IIIlFormulilEdltor@JudulF 1~I~LRl

B l:;Ol-&l,Heporlrleld, 29 El-4Q;runCllom

..!J - ""'[OrderDel~ih].OrderiD .!.I El(fM~lh

"'" [Order Del~ih].ProductID $--1'0 Summ~r~

~@JuduIF EllOFin~ncial

ru ?J~dul ElI'OSlrings

i±l'·IIlNorlhwind[MicrowIlSQLServerj El"~Dale/Time

El"!lfD~leRanges ~filArrays El"lOTypeConversion

El .. (f Programming Shortcub El"~EvalualionTime El!lfPrinlStale ~"filDoc~menIProperlies EllOAlerlo i±l(fAddilion~IF~ndiom

ii B '!I~";~:::""

e Conversion

00.. Comp~rigon'

S Sirings

S" Ranges

a Boolean S· Arra~"

00 .. Patlern

e Control Slrud~re"

i±l .. Olher

m Scope

. ,-" ...

I"H"ran

4) Tekan Save

5) Close

Catatan:

Rumus pada formula harus berupa nilai pernyataan yang mengembalikan nilai benar atau salah

4

Created by : Agus Indra Cahaya Website: http:((cybercatzone.net

PROSES PADA VISUAL BASIC

a. Parameter

Ada 3 metode :

1) Menggunakan I .ParameterFields.GetltemByName("nama_parameter") .. AddCurrentValue I Cth: dengan Project diatas

vRpt.ParameterFields.GetltemByName("Judul").AddCurrentValue "Aneh Judulnya"

2) Menggunakan I .ParameterFields.ltem(nomor_paramter) .. AddCurrentValue I Cth: dengan Project diatas

vRpt. ParameterFields.ltem(l).AddCurrentValue "Gelo euY"

3) Menggunakan I .ParameterFields(nomor_paramter) .. AddCurrentValue I Cth: dengan Project diatas

vRpt. ParameterFields(l).AddCurrentValue "Bisa teu"

Chat: sonic_error I cybercatzone

Mail: sonicerror@yahoo.comlcybercatzone@yahoo.co.id

b. Formula

Menggunakan I .FormulaFields(nomorJormula).Text I Cth: dengan Project diatas vRpt.FormulaFields(l).Text = "'Formula Geto'"

Catatan:

Nomor Parameter atau Formula sesuai dengan jumlah parameter atau formula yang dibuat, jika jumlah parameter 1 maka nomor_parameter =1 begitu juga untuk formula.

5

Master your semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master your semester with Scribd & The New York Times

Cancel anytime.