Crystal Reports 10.2 Error in SelectionFormula???
I have attached the Error Message as a Word Doc so it can be viewed. I'm not sure if the Selection Formula is syntactically correct. I've also included the code that generates the report below:
Code:
Public Sub TimeByProject(ByVal intMO As Integer, ByVal intYR As Integer)
Try
strModule = "modReporting"
Dim crDOC As New rptTimeByProject
Dim strSelectionFormula As String = ""
crConnectionInfo = New ConnectionInfo
With crConnectionInfo
.ServerName = "ServerName"
.DatabaseName = "SCTime"
.IntegratedSecurity = True
End With
crDB = crDOC.Database
crTables = crDB.Tables
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
crTable.ApplyLogOnInfo(crTableLogOnInfo)
Next
frmReports.rptViewer.DisplayGroupTree = False
strSelectionFormula = "month({tblTimeSheetDetail.beginPeriodDate}) = " & intMO & " AND year({tblTimeSheetDetail.beginPeriodDate}) = " & intYR
crDOC.RecordSelectionFormula = strSelectionFormula
frmReports.rptViewer.ReportSource = crDOC
frmReports.ShowDialog()
crDOC = Nothing
crDB = Nothing
crTables = Nothing
crConnectionInfo = Nothing
Catch ex As Exception
End Try
End Sub
Re: Crystal Reports 10.2 Error in SelectionFormula???
Re: Crystal Reports 10.2 Error in SelectionFormula???
Well, based on the error message, Crystal does not recognize that the {tblTimeSheetDetail.beginPeriodDate} field is a Date/Time field.
Check the database. Is it a date/time field or perhaps its a string field that contains date data?
Has the database changed after the report was initially created?
Re: Crystal Reports 10.2 Error in SelectionFormula???
Bruce,
It's a field that contains a date value, however, it's type is not a datetime.
Re: Crystal Reports 10.2 Error in SelectionFormula???
Then, to use the Month, Year functions you need to convert the field to a datetime data type. You could also use String functions Left, Right, Mid) to parse out the date part values.
month(cdate({tblTimeSheetDetail.beginPeriodDate}))