Personal Mind of ASEP

Sepercik Rasa yang Tercurah

Cara Nampilin Crystal Report 9 dan 10 di vb 6.0

Ini code gw ambil dari vbcode.com trus code ini di gunain buad munculin crystal report 9 ato 10

Option Explicit

Rem Developed By Byddhika Fernando
Rem Computer Programmer DSV Business Solutions (Pvt) Ltd.
Rem Sri Lanka
Rem charith_c7@yahoo.co.uk , gehan_g7@yahoo.com
Rem 071-4810847
Rem **********************************************
Rem *** Parameter Passing To Crystal Report ***
Rem *** ” For Version 9.0 / 10.0 ” ***
Rem *** Trough Visual Basic 6.0 ***
Rem *** First Report Normal Select Statement ***
Rem *** Second Report Using SQL View ***
Rem *** ************************************ ***
Rem *** Any Suggestions Reply To My E -Mail ***
Rem *** ***
Rem *** Enjoy With Codes ***
Rem *** ************************************ ***

Rem Create New Visual Basic Project [ Standard EXE ]
Rem Select Project Menu Then Add References
Rem Select Crystal Report ActiveX Designer Run Time Library 10.0
Rem Before You Add The Dll You Have To Install
Rem Crystal Report 10.0 Professional Version
Rem Select Project Menu Then Select Components
Rem Crystal ActiveX Report Viewer Library 10.0
Rem Add The Component Into Form
Rem Add Two Labels,Textboxs And Command Buttons
Rem I Used Category And Product Table In Northwind Database
Rem Goto Crystal Report Software And Create Two Reports
Rem Add Two Parameters To The Each Report
Rem Second Report You Have To Create Using SQL View
Rem If You Doesn’t Know How To Create View Use SQL Online Help
Rem After You Creating The Two Reports Come Back To VB
Rem Under Option Option Explicit
Rem Declare The Following Two Statements

Rem Customize Your Report According To Your Style
Rem Use The Following Codes To Complete It.

Private Cry As CRAXDRT.Application
Private Rep As CRAXDRT.Report

Private Sub CmdView_Click()

Rem Set The Screen Mouse Pointer Type
Screen.MousePointer = vbHourglass
Rem Disable The Command Control Until The Report View
CmdView.Enabled = False
CmdView2.Enabled = False
Rem Cry Is Object Variable So You Have To Use
Rem Set Command Before You Use The Cry Object
Rem To Learn More Refer Complete Visual Basic 6.0
Set Cry = New CRAXDRT.Application
Rem Open The Report
Rem You Have To Give Correct Report Path Between Semicolon
Set Rep = Cry.OpenReport _
(“E:\Crystal Reports\Visual Basic 6.0\SQL Server\Test_Parameter.Rpt”)
Rem Enable The Parameter Switch
Rem This Code Not Compulsory , Some Times You Have To Use This Command
Rep.EnableParameterPrompting = True
Rem Delete Previous Report Data
Rep.DiscardSavedData
Rem Clear The Previous Parameter Values
Rep.ParameterFields(1).ClearCurrentValueAndRange
Rem According To Your Report Parameters Pass The First Parameter Value
Rep.ParameterFields(1).AddCurrentValue Val(Text1.Text)
Rep.ParameterFields(2).ClearCurrentValueAndRange
Rem According To Your Report Parameters Pass The Second Parameter Value
Rep.ParameterFields(2).AddCurrentValue Val(Text2.Text)
Rem You Can Add Any No Of Parameters To Report
Rem When You Are Going To Pass The Valuse You Have Careful The Order Of The
Rem Parametrs And Types
Rem Refresh The Report Component Object
With CRViewer1
.ReportSource = Rep
.RefreshEx True
.Refresh
.ViewReport
End With
Rem Close The Cry Object Variable
Cry.CanClose
Set Cry = Nothing
Rem Set The Screen Mouse Pointer And Command Control To Default
Screen.MousePointer = vbDefault
CmdView.Enabled = False
CmdView2.Enabled = False

End Sub

Private Sub CmdView2_Click()

Rem In Here You Are Going To Same Above Coding
Rem But You Have To Ganearate The Report Using View

Rem Set The Screen Mouse Pointer Type
Screen.MousePointer = vbHourglass
Rem Disable The Command Control Until The Report View
CmdView.Enabled = False
CmdView2.Enabled = False
Rem Cry Is Object Variable So You Have To Use
Rem Set Command Before You Use The Cry Object
Rem To Learn More Refer Complete Visual Basic 6.0
Set Cry = New CRAXDRT.Application
Rem Open The Report
Rem You Have To Give Correct Report Path Between Semicolon
Set Rep = Cry.OpenReport _
(“E:\Crystal Reports\Visual Basic 6.0\SQL Server\Test_Parameter 02.Rpt”)
Rem Enable The Parameter Switch
Rem This Code Not Compulsory , Some Times You Have To Use This Command
Rep.EnableParameterPrompting = True
Rem Delete Previous Report Data
Rep.DiscardSavedData
Rem Clear The Previous Parameter Values
Rep.ParameterFields(1).ClearCurrentValueAndRange
Rem According To Your Report Parameters Pass The First Parameter Value
Rep.ParameterFields(1).AddCurrentValue Val(Text1.Text)
Rep.ParameterFields(2).ClearCurrentValueAndRange
Rem According To Your Report Parameters Pass The Second Parameter Value
Rep.ParameterFields(2).AddCurrentValue Val(Text2.Text)
Rem You Can Add Any No Of Parameters To Report
Rem When You Are Going To Pass The Valuse You Have Careful The Order Of The
Rem Parametrs And Types
Rem Refresh The Report Component Object
With CRViewer1
.ReportSource = Rep
.RefreshEx True
.Refresh
.ViewReport
End With
Rem Close The Cry Object Variable
Cry.CanClose
Set Cry = Nothing
Rem Set The Screen Mouse Pointer And Command Control To Default
Screen.MousePointer = vbDefault
CmdView.Enabled = False
CmdView2.Enabled = False

End Sub

source : vbcode.com

October 24, 2005 - Posted by | Uncategorized

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: