Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 4th, 2006, 03:28 AM
Registered User
Join Date: Nov 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change datasource of crystal report at runtime

Hi all,

This is Padma
I have a problem regarding crystal reports.

I have added a crystal report designer into my project.I have used MSaccess as the database and when I have added crystal report as a designer,code has been automatically added with CRViewer9 control to view the report.

Now my problem is that i have to change the datasource of the report at runtime

Code is like this

Dim Report as CrystalReport1


I have tried adding a line of code to change the database

Report.Database.SetDataSource(App.Path & "\DB.mdb")

but not working

If anybody can help me i would be thankful

Old March 21st, 2008, 05:45 AM
Registered User
Join Date: Mar 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts

  try this. this may help you.

Dim appl As New CRAXDRT.Application
Dim rep As New CRAXDRT.Report
Dim cpars As CRAXDRT.ParameterFieldDefinitions
Dim cpar As CRAXDRT.ParameterFieldDefinition

rep.Database.Tables(1).Location = App.Path & "\DataBase.mdb"

CRViewer91.ReportSource = rep

rep.EnableParameterPrompting = False
'If you use any parameter
rep.ParameterFields(1).AddCurrentValue "Instring"

rep.Database.SetDataSource rs


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable crystal report datasource dialogbox owen_xgy .NET Framework 2.0 2 November 21st, 2008 07:44 AM
change Datasource of a crystal report at run time tiyyob Pro VB 6 1 February 17th, 2007 06:05 AM
Creating a Crystal Report from a runtime dataset vbmazza ASP.NET 1.0 and 1.1 Basics 0 March 17th, 2006 07:40 AM
Sorting at runtime in Crystal report vidya ASP.NET 1.x and 2.0 Application Design 1 March 15th, 2005 01:57 AM
passing parameters at runtime using crystal report anilkumar Crystal Reports 2 January 3rd, 2004 01:35 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.