VB 4.0 and CR 4.0 error 20515 - Help! 
Author Message
 VB 4.0 and CR 4.0 error 20515 - Help!

I have upgraded an application from VB 3.0 to VB 4.0.  The app uses
Crystal Reports Pro 4.0.1.5.  The version of CR remains the same.  When
I run my VB app from the network, using report files located on the
network, everything works fine.  However, when my coworkers try to run
the same app on the network, they get an error:  "Run time error 20515,
Error in Function."  I am the only one with the VB and CR development
tools on my PC.  My coworkers had the original application, and
therefore should have all the necessary files to run a report made in CR
4.0.  My entire c:\WINDOWS\SYSTEM directory was copied to one of the
computers, but the problem did not go away.  I would appreciate any help
or ideas on the problem.  Thank You.

Robert Hughes



Sat, 01 Jul 2000 03:00:00 GMT  
 VB 4.0 and CR 4.0 error 20515 - Help!

Some tips:

20515 - Error in Formula (Troubleshooting Steps)(Summary) 96/05/13

Product: PR Version: ALL
Database: Database  Platform: WIN3x
Type: TIP Status:NEW

Problem:
 VBX - 20515 - Error in Formula (Troubleshooting Steps)

Solution:
 Possible Situations that might Cause this Error:
1) Crystal is unable to evaluate a formula in the report.  This occurs
commonly when a formula being passed to Crystal, is being set incorrectly
from an application.  Documents #4113 and #4136 from the Crystal
Fax-On-Demand system (604) 681-3450 address these issues.

These documents detail the passing of  formulas to the Crystal.VBX or OCX at
runtime. They cover Formulas, SelectionFormula, Group Selection Formula,
Sort Records, and Group Sort Record properties. When passing apostrophes to
formulas, use CHR(34) for double quotes and CHR(39) for single quotes.

2) A Selection Formula passed to Crystal from VB, using the SelectionFormula
property of the CRYSTAL.VBX will be appended to any selection formula
existing in the report. This is done with the use of an AND operator and
applies to  Crystal Reports version 3.0 and later.

For versions of Crystal prior to 3.0, the record selection formula passed in
from VB simply overwrites the formula already present in the report.

For Crystal Version 3.0 or later, always clear the selection formula in the
report (i.e. ensure that there isn't even an empty space in the report.)

3) Crystal Version 3.0 or later allows users to access Additional Functions
in report formulas.  The code for these functions actually exists externally
from CRW in files that begin with "UFL" and end with ".DLL" (eg.
UFLSAMP1.DLL).  These DLLs need to be in the same location as the CRPE.DLL
that is being loaded by an application for them to be found.

4) If the machine is running on Windows 3.x, ensure that SHARE.EXE /L:500
/F:5100 is loaded before Windows gets loaded.

Steps to Isolating and Solving the 20515 - Error in Formula:

(1) Go into Crystal Reports and go under Report | Edit Selection | Records.

Delete any selection formula you have here (anything that is present will
here will be appended to your runtime selection formula and will result in a
20515 - Error in Formula error message).

Also, move your cursor key down and to the right until it doesn't move.
Then, press your Backspace  key several times to make sure there are no
spaces in your SelectionFormula in Crystal (even if you have just a space
character here, it will cause an Error in Formula at runtime).

(2) Go under the Database menu and do a Verify Database.  Click on Verify on
Every Print (Database menu) and UNCHECK the option for Save Data with Report
(File menu)  or (Report Menu).

(3) Try to rerun your application.

(4) If an error still occurs, then comment out ALL SelectionFormula and
Formula properties from Crystal which you are using.

(5) Your report should now run and display correctly to the preview window
without any error messages. At this point, you should have isolated your
problem to your SelectionFormula and/or Formula  properties.

(6) Uncomment your formulas one at a time until you find out which
SelectionFormula and/or Formula property is resulting in the 20515 - Error
in Formula error message.

(7) If you are using several conditions in your SelectionFormula, you should
set each condition equal to a variable.  Then, you would test each condition
separately, and this would allow you to figure out which of your conditions
is failing.  A good tool to use is to Msgbox() your variable.  This will
allow you to view the exact syntax that would appear when passing your
formula to Crystal Reports.  From here, you might be able to see if you are
missing a quote or a bracket somewhere.  Remember that what is shown in the
MsgBox() function should work within Crystal Reports.

ex. RecSelect$ = "{company.state} = 'CA' "
      Report1.SelectionFormula = RecSelect$
      MsgBox RecSelect$
      Report1.Action = 1

ex. RecSelect$ = "{company.state} = '" & Text1.Text &  "'"
      Report1.SelectionFormula = RecSelect$
      MsgBox RecSelect$
      Report1.Action = 1

(8) Try out your selection formula within Crystal first of all.  Make sure
that the syntax is fine and also that your records are being filtered
correctly.

(9) Then, hardcode this selection formula to the SelectionFormula property
at runtime.  Make sure that you have deleted the original selection formula
in Crystal Reports as well as eliminated any spaces by backspacing.  In
Visual Basic, Msgbox() this original hardcoded selection formula.  Your
report should run properly to the preview window.  Make sure that you take
note of the exact syntax which is displayed in the Msgbox() value.

(10) When you build your selection formula, make sure to set each condition
to a variable.  Test each variable separately and use the Msgbox() function
to verify that you are passing the correct syntax.

(11) As your final step, you will append your many condition variables into
the final SelectionFormula.  Make sure to also MsgBox() this final
selection.

Your report should now be generated correctly.

ex. RecSelect1$ = "{company.STATE} = '" &Text1.Text& "'"
      RecSelect2$ = "{company.COUNTRY} = '" &Text2.Text& "'"
      MsgBox(RecSelect1$)
      MsgBox(RecSelect2$)
      RecSelect3$ =  RecSelect1$ + RecSelect2$
      MsgBox(RecSelect3)
      Report1.SelectionFormula = RecSelect3
      Report1.Action = 1

If you are still having problems, study the following documents from the Fax
on Demand System first:
- Document# 4113 - VB variables with SelectionFormula Property
- Document# 4136 - VB variables with Formulas() Property

If you are getting a 20515 - Error in Formula ONLY on a CLIENT machine (but
not on the development machine), make sure that you have brought any or all
of the "UFL*.DLL"s below (as they pertain to you):

UFLSAMP1.DLL
UFLDTS.DLL
UFLBAR.DLL
UFLTECH1.DLL

You can find these files under the list of Runtime Files (User Function
Libraries Specific Requirements). If you are missing one of these "UFL" Dlls
which the report is using, it will generate the 20515 error message.

If you are still having problems, call Crystal and provide the following
information:

(1) The record selection syntax that works within Crystal Reports.
(2) Hard-code the original selection formula into your visual basic
application and Msgbox() this value.  Make sure that you can preview the
report.  Provide Crystal with this MsgBox() value.
(3) Each condition should be set to a variable.  Msgbox() each variable.
When you know which variable is failing, tell the tech support rep this
particular Msgbox() value.
(4) Msgbox() the entire SelectionFormula.

Passing Apostrophes/Quotes in Variable Strings to Crystal
An Error in Formula can also be caused when trying to pass strings which
contain Apostrophes or Quote marks (either single or double).  For example:
O'Brian or 1 " Drum Cylinder.

(1) Example 1 (Passing Single Quote)

 Sub Command1_Click ()

   Rem This code sets a selection formula when there is a single quote in a
string.
   br$ = "O'Brian"
   Temp$ = "{Authors.Author} =" + Chr$(34) + br$ + Chr$(34) + ""

   MsgBox (Temp$)

   Rem The following line is the same as what the lines above do, but in a
hard-coded way.
   Rem Temp$ = "{Authors.Author} =""O'Brian"""

   Report1.SelectionFormula = Temp$
   Report1.Action = 1

 End Sub

(2) Example 2 (Passing Single Quote)
If you have a single quote in your variable(i.e. Mark's house is  really
small), do the following:

 fml$ = "{table1.text} = """" & Var1 & """"
 or
 fml$ = "{table1.text} = Chr$(34) & Var1 & Chr$(34)

 Report1.SelectionFormula = fml$

(3) Example 3 (Passing Single Quote)

  Sub Command1_Click ()

    fml$ = "{table1.text} = """ & Text1.Text & """"
    MsgBox fml$
    Report1.SelectionFormula = fml$
    Report1.Action = 1

    'fml$ = "{table1.text} = ""My mother's name"""
    'MsgBox fml$
    'Report1.SelectionFormula = fml$
    'Report1.Action = 1
    'fml$ = "{table1.text} = 'My mother's name'"
    'MsgBox fml$
    'Report1.SelectionFormula = fml$
    'Report1.Action = 1

 End Sub

(4) Example 4 (Passing Double Quote)
If you have a double quote in your variable (i.e. 1" drum cylinder), then
use:

 fml$ = "{table1.text} ='" & Var1 & "'"
 Report1.SelectionFormula = fml$

(5) Example 5 (Passing both Single and Double Quote)
If you wanted to pass the following text to Crystal from VB:
"Did you know that a foot has 12" in it, and it's never any shorter".

Use the Chr(34) which is a double quote and Chr(39) which is a single quote
to pass to Crystal.  The easiest way to work this out is to do the formula
in CRW first and run the report.  If it's successful, then write the syntax
down followed by using the Chr(n) to substitute the quotes with.

 Report1.Formulas(0) = "Did you know that a foot has 12" + Chr(34) +
  " in it, and it" + Chr(39) + "s never any shorter."

 MsgBox report1.Formulas(0)
  Report1.Action = 1

c1344375

--
Best Regards,
Jonathan

Please do not respond directly to this post via email.
Send any email questions to our email support groups as
listed in your Help | About window from Crystal Reports.

For our Knowledge Base on the Web, visit
http://www.seagatesoftware.com/crystalreports/techsupp/

Quote:

>I have upgraded an application from VB 3.0 to VB 4.0.  The app uses
>Crystal Reports Pro 4.0.1.5.  The version of CR remains the same.  When
>I run my VB app from the network, using report files located on the
>network, everything works fine.  However, when my coworkers try to run
>the same app on the network, they get an error:  "Run time error 20515,
>Error in Function."  I am the only one with the VB and CR development
>tools on my PC.  My coworkers had the original application, and
>therefore should have all the necessary files to run a report made in CR
>4.0.  My entire c:\WINDOWS\SYSTEM directory was copied to one of the
>computers, but the problem did not go

...

read more »



Sat, 01 Jul 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB 4.0 and CR 4.0 error 20532 = Help!

2. VB 4.0, CR 4.0, and MS Access 2.0 - a strange problem

3. Error 20515 error in formula

4. VB 4.0 16-bit Bug with OLE (Was Re: VB 4.0 Enterprise and OLE)

5. VB 4.0 disappointments / Just Say No to VB 4.0

6. Error 20515, on selection formula?

7. Crystal choking on 20515 Error

8. Error 20515 - the field name is not known

9. runtime error '20515'

10. Error 20515

11. RunTime Error 20515

12. Error 20515

 

 
Powered by phpBB® Forum Software