I've got a client database working, and I need to have a field called 'ClientNo' that needs to get a sequential number put into it.
The behavior I want is this:
User opens the "CLIENTS" form in Add mode, and so 'On-Form-Entry' I want to put a global value 'gvClientNo' into the 'ClientNo' field on the form.
Then, when the user finally saves the record 'On-Form-Exit' I want the programming to use XLOOKUPR to determine the highest value for 'ClientNo' in the database, to be sure that another user hasn't already saved a record with the same value. If there's a problem I would bump up the ClientNo by one, and then save and update the globalvalue.
The problem I'm running into is the @XLOOPUPR() function. Everytime I use it, I only get zero back. I'm using the programming from the one-sheet on numbering, which can be found here:
http://www.lantica.com/Support/sesame_onesheet_11.html // 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
}
}
}
So my programming looks like this:
var vNextNum as Int
vNextNum = @ToNumber(@XLookupR(@FN, "9999999", "ClientNo", "ClientNo"))
If Not @Error
{
ClientNo = vNextNum
Write("The new ClientNo is: " + vNextNum)
}
But when I run it, all I get is '0' as the value of vNextNum.
What am I doing wrong with XLookupR?