Error In Formula in VB but not if I run the report separtely 
Author Message
 Error In Formula in VB but not if I run the report separtely

I have a report that I would like to call using various dates. The
strSeelct works if copied and pasted into the report in Crystal but
gives me an "Error in Formula" error number 20515 in VB. Any
suggestions as Seagate's KB won't let me access this info, the KB
keeps coming back with an error.
Private Sub cmdOK_Click()
    Dim iResult As Integer

    If Not IsDate(txtStart) Then
        MsgBox "Please enter a valid date."
        txtStart.SetFocus
        Exit Sub
    End If

    Select Case gsReportTitle
    Case "appaidpieces.rpt"
   strSelect = "{Payments.PaymentDate}=DATE(" & Format(txtStart,
"yyyy, mm, dd") & ")"
    End Select
    CrystalReport1.DataFiles(0) = gsDBName
    CrystalReport1.ReportFileName = MYPATH & gsReportTitle
     'select our records
    CrystalReport1.SelectionFormula = strSelect

    'preview the report
    CrystalReport1.Destination = 0
    iResult = CrystalReport1.PrintReport
    If iResult <> 0 Then
        MsgBox CrystalReport1.LastErrorString
    End If

End Sub
For some reason this does not work.



Wed, 05 Jul 2000 03:00:00 GMT  
 Error In Formula in VB but not if I run the report separtely

I think the problem may be with the commas.  A coworker of mine must have
run into this same problem since he formats the date string as follows:

                sValue = "Date(" & _
                    Format$(DateEdit1(i), "yyyy") & "," & _
                    Format$(DateEdit1(i), "mm") & "," & _
                    Format$(DateEdit1(i), "dd") & ")"

I doubt that he'd have used three lines and concatenated the commas
separately if he didn't have to, hence my conclusion that they were messing
up your format string.  

Hope this helps.  



Quote:
> I have a report that I would like to call using various dates. The
> strSeelct works if copied and pasted into the report in Crystal but
> gives me an "Error in Formula" error number 20515 in VB. Any
> suggestions as Seagate's KB won't let me access this info, the KB
> keeps coming back with an error.
> Private Sub cmdOK_Click()
>     Dim iResult As Integer

>     If Not IsDate(txtStart) Then
>         MsgBox "Please enter a valid date."
>         txtStart.SetFocus
>         Exit Sub
>     End If

>     Select Case gsReportTitle
>     Case "appaidpieces.rpt"
>    strSelect = "{Payments.PaymentDate}=DATE(" & Format(txtStart,
> "yyyy, mm, dd") & ")"
>     End Select
>     CrystalReport1.DataFiles(0) = gsDBName
>     CrystalReport1.ReportFileName = MYPATH & gsReportTitle
>      'select our records
>     CrystalReport1.SelectionFormula = strSelect

>     'preview the report
>     CrystalReport1.Destination = 0
>     iResult = CrystalReport1.PrintReport
>     If iResult <> 0 Then
>         MsgBox CrystalReport1.LastErrorString
>     End If

> End Sub
> For some reason this does not work.



Sat, 08 Jul 2000 03:00:00 GMT  
 Error In Formula in VB but not if I run the report separtely

Hi Chris,

Your code looks fine.  Try this, if you print strSelect to the Debug
window and cut and paste it into the report in Crystal, does it work or
does it return an error as well?  I'm wondering if there is something
wrong with how the formula is being built.  

I do this to test my formulas.  If the formula won't work in Crystal, it
won't work in code either.
--
Sincerely,
Brian Dong

Please remove nospam from the address to reply.



Sat, 08 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error in formula when I run rpt from VB App

2. Crystal Reports 6 control does not clear formulae when you change report

3. Changing a formula @ Run Time - Report Designer Component

4. Crystal Report not running in VB 6

5. Formula field in sub-report not showing up in Excel export

6. error 20525 Error in Formula From Access VB

7. Error 536 Unable to connect when I run a crystal report from VB 4.0

8. cristal report formula error

9. VB 6.0 run-time error 48 - File not found: Kernel

10. Error 536 Unable to connect when running Crystal Report from VB 4.0

11. compiled VB proj exhibits run time error, but not in IDE/debug

12. VB.NET - CR errors when running report on hierarchy mith multiples at same level

 

 
Powered by phpBB® Forum Software