Add Calculated Field doubt

  • Thread starter Andrew Ofthesong
  • Start date
A

Andrew Ofthesong

Hi... I have this:

Set fsNewFieldSet = oView.AddFieldSet("ResponseRateA")
fsNewFieldSet.AddCalculatedField "ResponseRateB", "ResponseRate",
"fldResponseRate", "(fldC/fldB)"

And works fine... However, if i try to make an if:

Set fsNewFieldSet = oView.AddFieldSet("ResponseRateA")
fsNewFieldSet.AddCalculatedField "ResponseRateB", "ResponseRate",
"fldResponseRate", "=if(fldB=0,0,(fldC/fldB))"

i get an error...

i searched MSDN i it says "Expression Required String. The expression used
to calculate the items in the new field. The expression must be compatible
with the Jet expression service."...

What Am'i doing wrong??
 
D

Dip

Hi,

Just a thought,



Set fsNewFieldSet = oView.AddFieldSet("ResponseRateA")

fsNewFieldSet.AddCalculatedField "ResponseRateB", "ResponseRate",

"fldResponseRate", "=if(fldB=0,0,(fldC/fldB))"



From this code, can you remove "=" and use "IIF" instead of "IF" the try
coding like this?



"fldResponseRate", "IIF(fldB=0,0,(fldC/fldB))"

This should work.

Dip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top