Mutiplication between 2 fields?

Hi,I have 2 editable fields:

Field1 as number

Field2 as number

and I have a computed field for display Results with that formula:

@TextToNumber(field1)*@TextToNumber(field2)

Why I got this error : @error in my Results ??

Thanks for your help

Subject: Mutiplication between 2 fields ??

The fields are already numeric, so you don’t need to use @texttonumber. If the computed for display field is a text field, you need to do something like this:

@Text(field1 * field2)

Better yet, just change it to a numeric field as well…

hth

brandt

Subject: Mutiplication between 2 fields ??

If FieldOne and FieldTwo are both numbers then the @TextToNumber is not needed just FieldOne * FieldTwo

If you could use @If(@IsNumber(FieldOne);FiledOne;@TextToNumber(FieldOne))

If the FieldOne’s datatype is unknown.

Subject: RE: Mutiplication between 2 fields ??

Hi,I don’t understand, I did that already and it doesn’t work I got this message:Field “Result”: incorrect data type for operator and @function : number expected.

And all my 3 fields are numeric !!!

Subject: RE: Mutiplication between 2 fields ??

when are you getting the error, when you try and compse a doc? That’s probably because the number fields are blank (not numeric) and your computed field cannot calculate it. Either give the number fields a default value of zero (0) or change the formula in your computed field to ignore the formula if the fields are blank.

Subject: RE: Mutiplication between 2 fields ??

I don’t know what to do, I just put 0 to Field 1 and Field 2 as default.And now, I am getting always 0 as result !!!

Subject: RE: Mutiplication between 2 fields ??

I don’t know what to do, I just put 0 to Field 1 and Field 2 as default. >And now, I am getting always 0 as result !!!

0*0=0

So far it is correct. What if you enter different values in both (!) of the fields? May be you need to trigger a refresh (F9) if your form is not set up to automatically refresh fields…

UEK

Subject: RE: Mutiplication between 2 fields ??

I really don’t undestand what’s wrong !!I did all you asked me, I set the form "Automaticcaly refresh fields " .

nOTHING HAPPENNING !!! iS ANYONE CAN SEND A SAMPLE BY EMAIL ???

Subject: I have a theory; Test your form like this

Create a new document using your form

Field 1 will default to 0

Fied 2 will default to 0

The result shows a 0

Put the cursor to field 1 enter in a value (say 5 )

go to field 2 put in a value (say 7 )

Press F9

does the result field now show correctly ( i.e 37)

IF NO then yiou have a different problem than I had expect

IF YES

then I belive I understand your issue.

the default behaviour of a Notes form does not automatically recalculate the document using the calculations

just because you have changed a field

(that could be inefficient if you were making many changes to eneterable data)

The F9 causes a recalculate - giving the right answer

Now dont worry your user wont always have to press F9

there are several machanism to force a recalculate

but which one is best for you will depend on what teh form/document is doing.

We can deal with that later . For now just do the test and confirm or deny my speculation :=)

Subject: RE: I have a theory; Test your form like this

Yes F9 is working but I don’t want the user Refresh the form by pressing F9 .Ok so what’s the solution please

Subject: Several ways to approach this …

You’ve already covered one:

on teh form properties there is the “Auto Refresh Field” checkbox

what this does is every time the user moves from one field to another it recalculates

(test this simply by putting data in field 1 then in field 2 and moving cursor back to field 1 - the result should change)

The down side of this method is that you have to move out of the field for the recalc to trigger - which may not be an issue depending on the design of your form

If you think this is a bad method - Think a while

spread sheets, web pages often work this way too

and do you want the whole foprm changes just as you type each digit?

Note:

in any case there is an automatic recalculation BEFORE the document is saved

(test this by adding data in field 1 then in 2 , result will be wrong

leave entry cursor in field 2, save using mouse and reopen - hey presto result oK)

A third way is to have a recalc button - lots of web forms e.g. mortgage calculators do that one

many users dont feel this an issue - especially if at the end of the filled in form

The button or action uses @Command( [ViewRefreshFields] )

There are other methods -

some suitable only for specialised circumstances

some needing careful implementation

Think whether the simpler methods are good enough

remember the old programmers adage

dont let the aspiration for the ideal make you lose sight of the adequate thats within easy reach :=)

Subject: RE: Several ways to approach this …

Thanks for your help, I really appreciate.

Subject: RE: Several ways to approach this …

You can put some code in the Exiting Event of your input fields to refresh the doc when the user tabs out. Or you could use a prompt or dialog box to ask for the input and refresh the doc on close.

Subject: RE: Several ways to approach this …

An alternative, less performance costly (only triggers a document refresh when these two fields happen to change) method can be accomplished in this manner:

Make sure that all three fields are numbers and it doesn’t matter if you have a default value in any of the fields or not.

Set the Result field’s default value formula to Result (write the field name in the value formula area.)

Then in the Form’s globals area create the following function:

Function CalculateFields() As Boolean

Dim uiwkspace As New NotesUIWorkspace

Dim uiDoc As NotesUIDocument

Set uiDoc = uiWkspace.CurrentDocument

uiDoc.Document.Results = Null

CalculateFields = False

If Isnumeric(uiDoc.Document.FieldA(0)) Then

	If Isnumeric(uiDoc.Document.FieldB(0)) Then

		uiDoc.Document.Results=uiDoc.Document.FieldA(0)*uiDoc.Document.FieldB(0)

		CalculateFields=True

	Else

		uiDoc.Document.Results=0

	End If

End If

End Function

Then in FieldA’s and FieldB’s OnChange event, Client-Lotuscript script Call CalculateFields()

The two fields’ Onchange event should each look like this:

Sub Onchange(Source As Field)

Call CalculateFields()

End Sub

I have the function returning a boolean so you can do error trapping if you want, but it really doesn’t matter (if you don’t care about trapping/handling errors.)

Subject: Mutiplication between 2 fields ??

any ideas?

Subject: RE: Mutiplication between 2 fields ??

I would recommend taking a Lotus notes programming class if you are going to be doing Notes development. There are also alot of resources and books available.

This forum is not the place to be learning lotus notes from other experts. Its to post issues and coding problems to see if other people have run into them and offer up a solution.

I don’t mean to be negative, but what you are attempting to do is simply multiply 2 numbers - you have wasted 2 days (of your time and others) trying to get this to work which Lotus Notes developers can make happen in 2 minutes.

Your post from yesterday:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/3b828da98e4fb17985257274005bd3a2?OpenDocument

Subject: RE: Mutiplication between 2 fields ??

I think before saying stupidity, you have to take a look to my posting to understand what my issues. The problem is not calculate 2 numbers but getting the result instantly !!!

Subject: RE: Mutiplication between 2 fields ??

I read both your posts and all the responses.

I did not call you stupid, I am simply stating if you had a better understanding of Lotus notes, this is a trivial development item to make happen which any notes developer can do in a matter of minutes.

Sorry if I offended you - I am simply stating take a class and you will realize how easy what you are trying to do is to accomplish.

All of us notes developers get paid to code this type of thing for our customers and you want free code. We are all volunteering our free time in this forum to help other people - we are not getting paid to give you free code.

Take a class or hire a consultant !!!

Subject: RE: Mutiplication between 2 fields ??

Tom did not call you stupid, but your question left a lot to be desired.

You should take a look at this post: http://www-10.lotus.com/ldd/nd6forum.nsf/0/410171d83ddba6d485256df100832aba?OpenDocument

In another tech forum I read, the idea of posting 'the goal, not the symptom/step" is a good idea to follow…