Lantica Software LLC.
Learn more about Sesame Database Manager
You will find that besides Sesame being a great product the support that Lantica gives to us end users is second to none.
Robert Scott
-
 

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 @XLookupR

Assign Next Number Using @XLookupR

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

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(@XLookupR(@FN, "9999999", "Key", "Key")) + 1
		If Not @Error
		{
			Key = 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

@XLookupR()
Programming Guide - Page 130 - 131

Alternate Method
See the Sesame One-Sheet Assign Next Number Using a Global Value.

  Learn more about Sesame Database Manager
The Sbasic programing worked great and actually is easier than using macros.
  Bruce K. Stone
City Manager - City of the Village