Run time error 20515

Run Time error '20515'
Error in formula <CM_OPN_AMT>.
'IF {@OpnBal} = '0' THEN ({Temp_Clnt_PrvAmt.CMAmt}) - ({Temp_Clnt_PrvAmt.Amt_Rcvd})'
A number is required here.

Formula i am using is

IF {@OpnBal} = '0' THEN ({Temp_Clnt_PrvAmt.CMAmt}) - ({Temp_Clnt_PrvAmt.Amt_Rcvd})

Please help.
Altaf PatniSoftware DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


IF {@OpnBal} = 0 THEN ({Temp_Clnt_PrvAmt.CMAmt}) - ({Temp_Clnt_PrvAmt.Amt_Rcvd})

Are the other fields numbers or strings?

Altaf PatniSoftware DeveloperAuthor Commented:
it says string required here
and cursor shows me before 0
all the fields are number
What is the OpnBal fomula?

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Altaf PatniSoftware DeveloperAuthor Commented:
getting OpnBal value from vb form

prvOpnBal = Val(Rs2Clnt.Fields(0)) - Val(Rs2Clnt.Fields(1))
CrystalReport1.Formulas(5) = "OpnBal = '" & prvOpnBal & "'"
What is OpnBal in the report?
Since you replace it, the replacement is causing the problem

Altaf PatniSoftware DeveloperAuthor Commented:
OpnBal is a value i wanted to show in the report.
value from database.
then i wanted to calculate this OpnBal value with "Sum of CLNT_Ledger.CMAmt"
You say the error is in this formula

IF {@OpnBal} = '0' THEN ({Temp_Clnt_PrvAmt.CMAmt}) - ({Temp_Clnt_PrvAmt.Amt_Rcvd})

Need to know if that formula is part of the report or the formula you are changing from code?

If it is not the formula you are changing then what is the original formula?

Altaf PatniSoftware DeveloperAuthor Commented:
as far as i tried with different different ways

///trying to add Sum ({CLNT_Ledger.CMAmt}, {CLNT_Ledger.conName}) in @OpnBal
formula for CM_OPN_AMT is

IF {@OpnBal} = '0' THEN Sum ({CLNT_Ledger.CMAmt}, {CLNT_Ledger.conName}) else
({@OpnBal}) + Sum ({CLNT_Ledger.CMAmt}, {CLNT_Ledger.conName})

it says string is required here cursor shows between + and Sum
OpnBal is apparently a string value.

Is it a formula or a parameter?


Simplifying this to

Val({@OpnBal}) + Sum ({CLNT_Ledger.CMAmt}, {CLNT_Ledger.conName})

If OpnBal = '0' then the Value is 0 and doesn't change the sum


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Altaf PatniSoftware DeveloperAuthor Commented:
Tried but
On refresh report, no error
but from code
giving me run time error 20515
Please check attached File
Can you upload the report and show the code you use to run it?

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.