Crystal Report Error : File Could not be found "TableName", at file Location:"TableName"

Hi,
I am Using Vb6 and Seagate Crystal Report 8.0
i am trying to export excel directly by coding

Reports =C:\Sample_Report.rpt
Database = C:\Sample.mdb
Exe=C:\Sample.exe


to be easy i use the following code
Crt1.ReportFileName = "C:\Sample_Report.rpt"
Crt1.SelectionFormula = ""
Crt1.DiscardSavedData = True
crReport.ExportOptions.DestinationType = crEDTDiskFile
Crt1.Destination = crptToFile
Crt1.PrintFileType = crEFTExcel80Tabular
Crt1.PrintFileName = "C:\REPORT.XLS"
Crt1.Action = 1

I GOT exported to excel file but heading and title are not

exporting and column width not taking details

to overcome this i search and got the following code

Private Sub Report_ExportToExcel(ReportPath)
On Error GoTo Loc
Dim a
Dim path1
 path1 = Save_Dialog    '///open save dialog and get path to

save excel file
If path1 = "" Then Exit Sub

    Dim appl As New CRAXDRT.Application
    Dim dbTable As CRAXDRT.DatabaseTable
    Dim rep As CRAXDRT.Report
    Set rep = appl.OpenReport("C:\Sample_Report.rpt", 1)

    rep.DiscardSavedData
 
     For a = 1 To rep.Database.Tables.Count
        rep.Database.Tables(a).Location = "C:\Sample.mdb"
       rep.Database.Tables(a).SetLogOnInfo "C:\Sample.mdb",

"Sample.mdb"
    Next
   
    rep.ExportOptions.DiskFileName = path1
    rep.ExportOptions.DestinationType = crEDTDiskFile
    rep.ExportOptions.ExcelAreaType = crDetail
    rep.ExportOptions.ExcelUseTabularFormat = True
    rep.ExportOptions.ExcelTabHasColumnHeadings = True
    rep.ExportOptions.FormatType = crEFTExcel80Tabular
    rep.Export False
   
Exit Sub
Loc:
 MsgBox Err.Description
 
End Sub

From This "Report_ExportToExcel" Code i got my actual output

i have another set of code for Preview of crystal Report, i

am using this for whole project
Private sub Preview()
Crt1.ReportFileName ="C:\Sample_Report.rpt"
Crt1.SelectionFormula = ""
Crt1.DiscardSavedData = True
Crt1.WindowState = crptMaximized
Crt1.Action = 1
End Sub

Now i have export and preview seperately with different code

i can run the code "Report_ExportToExcel(ReportPath)" as many

times i want and i can run preview, there is no error

but

after run the preview code, i get error while running

"Report_ExportToExcel(ReportPath)"  code

i get error as i attached in the image

Error Details as follow

Titled as : Seagate Crystal Reports: Database Error

Error opening file.

File could not be found: "Callvisitreport", at fie location:
"Callvisitreport"


here Callvisitreport is TableName,
i have 300 + report developed in this version so i couldn't

change to another version
Please someone help to solve this error i need both export

and preview to be work fine, where i have done the mistake
thanks in advance
CRM procrmAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gustav BrockCIOCommented:
My guess is, that you are not allowed writing to the root of C:. Even if you are, it's a very bad idea.

Create a subfolder, say Test, grant full rights this for "Users", and then use C:\Test throughout.
0
mlmccCommented:
Is this in the same application?

You are using 2 different methods for the preview and export.

The export uses the CRAXDRT method and the preview is using the older method.  I don't believe the 2 are compatible in the same application.

YOu should try to use the CRASDRT method for both previewing and export.

Did you include a viewer in the application?

mlmcc
0
CRM procrmAuthor Commented:
Hi Gustav Brock

I try with D Drive..
d:\Testing\

Result was same
0
Powerful Yet Easy-to-Use Network Monitoring

Identify excessive bandwidth utilization or unexpected application traffic with SolarWinds Bandwidth Analyzer Pack.

CRM procrmAuthor Commented:
Hi mlmcc

Yes both are in same application only

i am not using viewer
for export viewer not needed

can i know any sample code to make both preview and export to be work??
0
mlmccCommented:
You don't have a viewer added?

The preview code uses a viewer and it has to be added to the application.

I'll try to find my code that uses CRAXDRT for both viewing and exporting.  On an older machine not sure if it still works.

mlmcc
0
CRM procrmAuthor Commented:
@mlmcc

Yes not added viewer friend of mine said that viewer procedure was lengthy step so i was recommended by short code but it was old format
please show me some sample code which works both for preview and export, let me check it out
0
mlmccCommented:
YOu need to add a form to the report and put the crviewer on it.

Here is code that should work
CRViewer91 is the name of the viewer object on the form

 Dim crAPP As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set Report = crAPP.OpenReport(App.Path & "\report1.rpt")
Report.SQLQueryString = "select * from report where indexx>25 order by indexx"
CRViewer91.ReportSource = Report
CRViewer91.DisplayGroupTree = False
CRViewer91.EnableExportButton = True
CRViewer91.EnableSearchControl = True
CRViewer91.EnableToolbar = True
CRViewer91.Refresh
CRViewer91.ViewReport
Set Report = Nothing
Set crAPP = Nothing

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CRM procrmAuthor Commented:
@mlmcc

Thanks for the code you are great, This code worked but i have an doubt

i tried as below
Dim crAPP As New CRAXDRT.Application
Dim Report As CRAXDRT.Report
Set Report = crAPP.OpenReport(App.Path & "\Sample_Report.rpt")

'Report.SQLQueryString = "select * from Callvisitreport where comno>'1' order by CallDate" '////Commented on Error : error1.png
FrmReporViewer.Show
FrmReporViewer.WindowState = 2
FrmReporViewer.CRViewer91.ReportSource = Report
FrmReporViewer.CRViewer91.DisplayGroupTree = False
FrmReporViewer.CRViewer91.EnableExportButton = True
FrmReporViewer.CRViewer91.EnableSearchControl = True
FrmReporViewer.CRViewer91.EnableToolbar = True
'FrmReporViewer.CRViewer91.Refresh '///Comment on Error  : Run-Time Error '-2147417848 (80010108)': Method 'Refresh' of object 'ICrystalReportViewer3' failed   : Error2.png
FrmReporViewer.CRViewer91.ViewReport
FrmReporViewer.CRViewer91.Top = 0
FrmReporViewer.CRViewer91.Left = 0
FrmReporViewer.CRViewer91.Height = FrmReporViewer.ScaleHeight
FrmReporViewer.CRViewer91.Width = FrmReporViewer.ScaleWidth
Set Report = Nothing
Set crAPP = Nothing

Open in new window


How to refresh the report? if it is already opened.  here refresh code getting error
and if i tryed without refresh, it show
Message : Memory Full

What needed to do refresh? pls assist me
error1.png
error2.png
0
mlmccCommented:
WHy are you trying to refresh a report through code?

If you need to you can refresh it as it opens.

There is a Saved Data option that can be set to FALSE which will force a refresh

mlmcc
0
CRM procrmAuthor Commented:
@mlmcc

acutally refresh via code is not working, by button only its working

if the report opened already , and we try at second time it gives "Memory full"

i Need to clear crviewer so that on second time even the report opened data get refreshed

how to do??
0
mlmccCommented:
So are you closing the viewer then running the report again?
If  the report is open the only way to refresh is through the refresh button on the viewer

mlmcc
0
CRM procrmAuthor Commented:
@mlmcc
Thanks for all replys

yes each time for report doing close and open..

i planned for two form, one left side for filtration and other on right side for report..

if i can refresh the report by code, then i can achieve this..

Is this possible??
0
mlmccCommented:
Yes, you can modify the selection formula.

I believe it is the ReportSelectionFormula object on the report.
Just set it o the where clause/filter

mlmcc
0
CRM procrmAuthor Commented:
@mlmcc

OK i ll try it and let you know
0
CRM procrmAuthor Commented:
Hi @mlmcc
I TRIED WITH record section formula
Report.DiscardSavedData
Report.RecordSelectionFormula = ""

refreshing already opened report
i get error "Memory Full"

but i got fix
Unload FrmReporViewer   

Open in new window

i used this before click of each time

so its work like refreshing the report, i achieved my result

@mlmcc thank you for the guidence
0
CRM procrmAuthor Commented:
My query has been solved thanks to mlmcc
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.