PDA

Click to See Complete Forum and Search --> : Crystal Reports 10.2 Error in SelectionFormula???


blakemckenna
Apr 9th, 2007, 03:49 PM
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:


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

blakemckenna
Apr 9th, 2007, 05:30 PM
any ideas on this???

brucevde
Apr 10th, 2007, 12:45 AM
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?

blakemckenna
Apr 10th, 2007, 09:00 AM
Bruce,

It's a field that contains a date value, however, it's type is not a datetime.

brucevde
Apr 10th, 2007, 09:51 AM
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}))