Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Negative Numbers

Status
Not open for further replies.

CNeeds

Programmer
Mar 24, 2004
111
US
What the best way for me to force a "-" negative in front of number based on a form name or etc?

I have 2 forms "Inventory" & "OrderInventory"

Inventory is a In-Take Form (Qty # needs to be +)
OrderInventory is a Out-Take Form (Qty # needs to be -) (This form is automatically generate from Order Form)

I have a view with Selection of (Inventory | OrderInventory Forms)
I tried at view level, figured out not the place - not sure how to do it on QuerySave on the form or etc.

Also, anyway to auto generate an invoice number on a form doc?

Thanks for any help & examples
 
If you want to act on the field level, use the Translation Formula and do your regular @IF(fieldname<0;fieldname;-fieldname) thing.
If you want to act at the view level, just use the same formula in the column where you show Qty for the take-out form, but control that the form is right :
Code:
@if(fieldname>0 & Form="OrderInventory";-fieldname;fieldname)

As for the invoice number, you can generate any random number in a number of ways. Somehow, I have the feeling that you want a sequential number. Not only that, but a sequential number that is globally unique and does not depend on who creates the invoice. Ouch. That is not a good idea for a number of reasons, the first being that Notes has never been developed around the database notion. Notes is not a relational database system, and sequential numbering is the very first trademark of a relation db.
You can create a sequential numbering system for individual users easily. Make a profile document for the user with the current number, and increment by one at each access by that user. You can even include some more code to make it a yearly counter. That is easy.
But making a sequential numbering system that will give one unique number that does not depend on the user is not guaranteed.
Oh of course, you can devise a global profile doc that contains the current number, include some collision-detection code to prevent two users from opening it simultaneously, and ensure that your code specifies that only one user can update it at a time. You can try, and you might even succeed - for a while. Unfortunately, the Domino engine was not built around that idea. That idea belongs to relational systems and, once again, Notes is not relational.
You could also try this in several different ways, but the end result is always the same : in Notes you are never 100% sure that your construct for a sequential number is viable. You will, one day, get a double. How you deal with that is something you'll have to decide when it happens.
As far as I'm concerned, Notes is not the right system to build sequential-number applications on. So, if you really need sequential, global numbers, have Notes ask an Oracle database for one. It's the only way you'll be sure.

Pascal.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top