Lantica Software LLC.
Learn more about Sesame Database Manager
In Lantica you have all put together what seems to be the finest approach to providing development software I have seen. Support, the website, and the attitude is far ahead of anything I have seen in our industry to date. Please keep up the good work.
John E. Fisher
Member - Business Information and Technology Solutions, L.L.C. (BITS)
 

Getting started with Sesame? Click here!
 
Home
Order Sesame
Products
Support
Contact Us
Company
Downloads
Q&A™
 
 
Email Address


Note: Your email address will be used only to notify you of updates and events related to Lantica and Sesame. Your address will not be sold or used for any other purpose.


Sesame Database Manager is compatible with Symantec Q&A. Q & A users will find that Sesame uses many of the same keystrokes, the same search syntax, and almost the same programming syntax as used in a Q&A database. Sesame can also translate Q&A databases. Find out more.


Inside Sesame - The Monthly Newsletter for Sesame Database Manager
Read a FREE issue!

 

Sesame Library | Sesame OneSheet - Assign Next Number Using a Global Value

Assign Next Number Using a Global Value

For some records, such as Invoices, you want to automatically assign the next record number when the record is saved. This method uses a Global Value.

1. Open your Form in Designer.

2. Open the Programming Editor by selecting Program Layout from the Commands Control Panel. Select your Form from the Element dropdown. Select On Form Exit from the Event dropdown.

Note: The On Form Exit event is used so that the next number is not used until the record is actually saved. If you want different behavior, you can move the code to whichever event you want.

3. Type the program in the Program Editor window.

// Only assign the number if 
// this is a new record which
// has been changed.

var vNextNum as Int

If(@IsNew)
{
    If(@Modified)
    {
        vNextNum = @ToNumber(@GlobalValue("NextNumber")) + 1
        Key = vNextNum
        GlobalValue("NextNumber", @Str(vNextNum))
    }
}

5. Test your program by selecting Test Program from the Test menu. Fix any syntax errors that are reported.

6. When you are finished, select Close Program Editor from the File menu. Your programming changes will be saved when you save your Form.

Don't forget to save and reconcile your changes!

When you save a new record, the next number will be automatically assigned.

 

More Information:
Using the Program Editor
Programming Guide - Page 15 - 24

@GlobalValue() and GlobalValue()
Programming Guide - Page 153 - 154

Alternate Method
See the Sesame One-Sheet Assign Next Number Using @XLookupR.

  Learn more about Sesame Database Manager
As a company, we are now comfortable that we are using fully supported, state of the art software to run our business. We no longer have Q&A Failure Anxiety!
  Paul N. Chevalier
Director of Quality and Product Engineering - Dia-Com Corporation