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

VFP 6.0 and CrystalReports 8.0

Status
Not open for further replies.

ipazzo

Programmer
Jan 17, 2002
69
IT
Hi friends.

I have developed an application with VFP 6.0 that imports data from text files and uses CR 8.0 for reports.
Now i have these needs:

1. give the user the possibility to create multiple database into wich import the datas.
2. give the user the possibility to select the database before printing a report.

Any suggestion ?


 
Ipazzo,

Yes, both of those are possible.

Your first question is not related to Crystal Reports. It is simply a matter of adding some logic to your import routine. It's hard to give specific advice without knowing more about your existing code.

For the second question, you need to adjust some properties in your report object. This depends on how you are accessing the data within Crystal. Are you using ODBC, or are you accessing native Foxpro data?

If you are using ODBC, you need to code something like this (where loRep is your report object):

loRep.databases,tables(1).name="NewTableName"
loRep.databases,tables(1).location="NewTableName"

(Yes, that's right. Set both properties to the same thing.)

If you have more than one table, repeat the above for each one, changing the subscript from 1 to 2, 3, 4,...

If you are using native access, you still need to change the Location property, but set it to the full path and filename of the table.

For more information about using CR 8.0 with VFP, see:

Hope this helps.

Mike



Mike Lewis
Edinburgh, Scotland
 
Thanks Mike for your help.
the link you suggested was a good starting point.

This is the code i wrote to change the database in the report:

LPARAMETERS lcFileName, lcNewDataBase, lcServerToChange
WITH This
.oCrystal = CREATEOBJECT"CrystalRuntime.Application")
.oReport = .oCrystal.OpenReport(lcFileName)
oDB = .oReport.Database
ocDBT = oDB.Tables
FOR i = 1 TO ocDBT.Count
oDBT = ocDBT.Item(i)
IF oDBT.LogonServerName = lcServerToChange
oDBT.SetLogOnInfo(lcServerToChange,lcDataBase)
ENDIF
ENDFOR
ENDWITH
 
Ipazzo,

Your code looks OK. What it is doing (I think) is to change to a different ODBC data source, which should work fine. The suggestion which I made earlier would have changed the table (or view) within the database, which of course is not the same thing.

Good luck with CR. Come back if you have any more questions.

Mike


Mike Lewis
Edinburgh, Scotland
 
And this for changing the database in the application:

lCancel = .f.
WITH THISFORM.cusCommonDialog
.FileName = ""
.DialogTitle = [Select Database]
.InitDir = gcAppPath
.Filter = [File database (*.dbc)|*.dbc]
ON ERROR lCancel = .t.
.ShowOpen()
ON ERROR
SET DEFAULT TO (gcAppPath)
ENDW
if !lCancel
lcFileName = ThisForm.cusCommonDialog.Filename
CLOSE DATABASE
OPEN DATABASE &lcFileName SHARED
use tmp in 0 exclusive
use trv in 0
use brd in 0
use mdl in 0
use config in 0
ThisForm.curdb = lcFileName
Thisform.caption = "Monitor - " + main.curdb

endif

Wow :D


Vito M.
 
I' haven't see your first comment: Your code looks OK.....

What it is doing is to change only the tables from my database in the report, so if the user creates it own reports linking tables from my database to others database only the links to my tables are affected ( IF oDBT.LogonServerName = lcServerToChange )

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top