Results 1 to 5 of 5

Thread: Crystal Reports 10.2 Error in SelectionFormula???

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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
    Blake

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: Crystal Reports 10.2 Error in SelectionFormula???

    any ideas on this???
    Blake

  3. #3
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    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.
    Blake

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    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}))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width