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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

report location changes on its own

Status
Not open for further replies.

hecktic

Programmer
May 14, 2002
84
0
0
CA
Hi,

I have an application with several reports. I have two databases from which the data is retrieved.

My problem is this: report1 is connected to database1 and
report2 is connected to database2

Both reports have nothing to do with each other. Let's say i make changes to report1, well, report2 will stop working because its location has been changed to database1 (and vice-versa).

I can fix it by using the setLocation menu command but I don't want to be doing this everything i modify a report.

I'm using CR8.5 with VB6+CRviewer.

Can anyone help out please?

Thanks for any help/suggestions.

 
Makes no sense to me unless the data source is file driven...

What sort of connectivity are you using?

Change the report to ODBC and I'll bet you won't see this again, it may be that the designer used the same data link file or some such.

-k
 
Don't want to set up odbc on every pc my app will run. And i have lots of reports which were all working fine until I added a report that uses another database.

So, i'm thinking it's a bug. I found some CR8.5 hot fixes but not sure if i should install them.
 
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
 
I'm using sql server, not access.
But i guess it should work the same.

I'll give this a try on monday.
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top