Lantica Software LLC.
Learn more about Sesame Database Manager
A great forum, quick, detailed responses, easy access to lists of problems and updates, and quick releases for needed fixes (especially for developers). Fantastic!
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 - Check For A Unique Value

Check For A Unique Value

For some key values, like a Customer Number, you want to make sure that the value is unique. This method can be used to check any value for uniqueness within its database.

1. Open your Form in Designer.

2. Open the Programming Editor by selecting Program Layout from the Commands Control Panel. Select GLOBAL CODE from the Element dropdown.

Type the program in the Program Editor window.

// Return value of 0 means NOT UNIQUE.
// Return value of 1 means UNIQUE.

Function CheckUnique() as Int
var vRetVal as Int
var vLVal as String
var vLEName as String

	vRetVal = 1
	vLVal = ""
	vLEName = @ElementName(ThisElement)

	vLVal = @XLookup(@FN, ThisElement, vLEName, vLEName)
	If @Len(vLVal) > 0
	{
		vRetVal = 0
	}

	Return(vRetVal)

End Function

3. Select the element you want to check from the Element dropdown. Select On Element Change from the Event dropdown.

Type the program in the Program Editor window.

var vUnique as Int

	vUnique = CheckUnique()
	If vUnique = 0
	{
		@MsgBox("Value is not unique!", "", "")
	}

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

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

You should add code to take whatever action is appropriate for your application if the value is not unique, or the check fails.

Don't forget to save and reconcile your changes!

NOTE: Remember, you can't test X command programming in Preview Mode.

 

More Information:
@XLookup()
Programming Guide - Page 127 - 128

  Learn more about Sesame Database Manager
The more I used it the more I like it, I do believe when I have mastered the basics it will be better. SBasic makes it really easy to program for me and having all my programming translated into Sesame was a big plus… Lantica tech-support is second to none, they are the best, I have received answers in hours…Great people great product, it can only get better from here.
  Robert Moore
Maintenance Supervisor (And IT person) - Greer Housing Authority