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!

Old report data remains

Status
Not open for further replies.

smil3y

IS-IT--Management
Jan 8, 2004
79
AU
Being a relatively new user of crystal I thought I was making progress. Managed to get all my reports working correctly - then discovered during my testing that one report is presenting false data (or data that was there previously). Using VB6 and crystal 8.5 I created the report and load the report initially with data from an Access 2000 database using the SQL statement below. This works fine the first time round.

SELECT Sum(manhours.Manhours) AS SumYearHours, Company.Company
FROM manhours INNER JOIN Company ON manhours.CompanyID = Company.CompanyID
WHERE (((manhours.RptDate)>0))
GROUP BY Company.Company, manhours.CompanyID;

This VB code segment loads the initial data

Private Sub LoadHoursReport()
HoursReport.DiscardSavedData
CRVReport.EnableGroupTree = False
HoursReport.txtHours.SetText "TOTAL HOURS WORKED"
CRVReport.ReportSource = HoursReport
HoursReport.CompanyName.SetText CompanyName
HoursReport.PaperSize = crPaperA4
CRVReport.ViewReport
CRVReport.Zoom 1
Screen.MousePointer = vbDefault
End Sub

I then have a couple of Date Time Pickers that allow me to refine the dates of the the query - this works fine all the time - VB code used is below:

My only problem is that if I select a date range - the report displays the data correctly and then I return to my normal application doing something else. If I open this same report up again it presents the same data that was there before I closed the report. ie it does not seem to want to display all my data as per my SQL statement above. I thought the 'DiscardSavedData' statements got rid of previous data. If I restart my application then the correct data is presented first time. Can someone help me please.




Case 13 'Manhours
sDate = "#" & Format((DTShowEndDate.Value + 1), "mm/dd/yyyy") & "#"
If CRVReport.IsBusy Then Exit Sub
Screen.MousePointer = vbHourglass
DTShowStartDate.Enabled = False
DTShowEndDate.Enabled = False
cboListing.Enabled = False
HoursReport.IsNoData = False

HoursReport.txtHours.SetText "PERIOD " & Format$(DTShowStartDate.Value, "dd/mm/yyyy") & _
" TO " & Format$(DTShowEndDate.Value, "dd/mm/yyyy")

SQL = "SELECT Sum(manhours.Manhours) AS SumYearHours, Company.Company" & _
" FROM manhours INNER JOIN Company ON manhours.CompanyID =" & _
" Company.CompanyID WHERE (((manhours.rptDate) >= #" & Format(DTShowStartDate, "mm/dd/yyyy") & "#" & _
&quot; AND (Manhours.rptDate) <&quot; & sDate & &quot;))&quot; & _
&quot; GROUP BY Company.Company, manhours.CompanyID&quot;

'Debug.Print SQL

rsadoReport.Open SQL, Con, adOpenDynamic, adLockBatchOptimistic
HoursReport.DiscardSavedData
HoursReport.Database.SetDataSource rsadoReport

If CRVReport.Visible Then
HoursReport.ReadRecords
CRVReport.Refresh
End If
DTShowStartDate.Enabled = True
DTShowEndDate.Enabled = True
cboListing.Enabled = True

End Select

Screen.MousePointer = vbDefault
End Sub
 
I tried that as well - went into DEFAULT SETTINGS and ensured that the DISCARD DATA when loading report was checked. Same thing happens.

It only happens with this report - thought it might be something to do with the SQL statement. What I might try doing is let crystal do the summing instead of the SQL and see if that makes a difference. Thanks anyway - but if you have any other ideas I would like to try and resolve it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top