This topic is locked

Why doesn't this work?

3/3/2009 10:37:18 PM
ASPRunnerPro General questions
R
Roger author

Trying to calculate a Total Amnt in the "Before Record Added Event" as follows (copied directly from)
' Parameters:

' dict - Scripting.Dictionary object.

' Each field on the Add form is represented as a 'Field name'-'Field value' pair
'** Custom code ****

' put your custom code here
dict("PurchaseTotal") = dict("ItemCost") * dict("ItemTime")*
BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record

' set it to False otherwise
The error that I get is an ASP Error: "Invalid Assignment"
It makes no difference what I use in this line. I've used Cdbl and even used "Literal Values". For Example:

dict("PurchaseTotal") = (16.0 * 2.5)*
Yet it works in "Before Record Updated Event", exactly like this: *dict("PurchaseTotal") = dict("ItemCost") dict("ItemTime")

It's likely something really stupidly simple, but these old eyes just can't see what I'm missing.
Thanks

J
Jane 3/4/2009

Roger,
It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

R
Roger author 3/4/2009

Hi Jane, thanks for the reply.
What I did was to move the logic into an SQL trigger.
I did this both for Add and Edit (SQL update trigger). It made a little more sense.
I didn't want to spin cycles on this and certainly didn't want to chew up space and bandwidth here on a seemingly simple issue. It's something simple that I didn't do, but onward and upward <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=38542&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
Also, it provides us with portability.
Thanks again for the prompt reply.
Cheers Roger.

Sergey Kornilov admin 3/4/2009

In most cases you need to convert values to numbers before applying your logic i.e.
dict("PurchaseTotal") = CDBL(dict("ItemCost")) * CDBL(dict("ItemTime"))
If you already tried that there must be something else that causes the trouble. Also you can use CSmartDbl that can handle null values as well.

R
Roger author 3/7/2009

Good point to remember for future items. I should have remembered to do that.
Oh well, onward and upward.
Thanks,
Roger