Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database access thru Crystal

Status
Not open for further replies.

2969

IS-IT--Management
Oct 18, 2001
107
US
Hi

Currently in my program I am using TTx method to pass recordset to the crystal rpt. But this method has a drawback that when I have to add a new field to the rpt, first we have to add it to the sql statement in the program so that the recordset when passed should have the field and value asscoiated with it.

Lot of our customers want to customize their rpts, is their a effecient way I can have them customize rpts without making a subsequent change in the program.

I thought of having the crystal use the DB connection and linking up the tables in crystal itself. But this way long time to get the data.

any ideas



 
Changing Database Location during Runtime

------------------------------------------------------------------
I am suprised to see a lot of people with this problem. I thought the Crystal people
are not even bothered with this problem or making it simpler for programmers.
However, i encounterred the same problem when i convert my .RPT files to using
Crstal report viewer control.

Im in love with this control but the problem of "..cannot open file" when changing the
database location during runtime nearly put me off. However, with the help of inspiration of
the Holy Spirit, i scaled through it.

Are you ready to go with me? Here lets go.
Please i am still using DAO data access because my program works very fine and i dont
have the
time to convert it to ADO data access.

If it works for your ADO data access please post your own contribution to me
--------------------------------------------------------------------
1. Add the Crysal Viewer control(.ocx) to your form - Form1.
2. Create your report with using the Crystal Report Designer component - CrystalReport1
3. Put the following code in the Form1 module

option Explicit
Dim oDB As New CRAXDRT.Application
Dim oTb As CRAXDRT.DatabaseTable
Dim Report As New CrystalReport1

Public strFormula as String 'Selectio formula property

Private Sub Form_Load()
Screen.MousePointer = vbHourglass

On Error GoTo HandleError

For Each oTb In Report.Database.Tables
oTb.Location = gdb.Name
'
'Note gdb is my database object
'gdb.Name returns the path name of the database
'e.g c:\VBProject\Stock.mdb
Next oTb


With Report
.DiscardSavedData 'refresh report data
.ConvertNullFieldToDefault = True
.RecordSelectionFormula = strFormula 'my selection formula like "{Stock.Class}='LS'"

CRViewer1.ReportSource = Report
CRViewer1.ViewReport
End With
End Sub


Run your code and change the database location and rerun it again.

Please post me if you encounter any error

Thanks.

Tunde Aransiola
tundearansiola@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top