Download Knowledge Base - DTP

Transcript
Corel
if eventInfo.errorCode() = peOK then ; Insert successful
tbl1.attach("CUSTOMER.DB")
nNewNum = tbl1.cMax("Customer No") + 1
Customer_No.value = nNewNum
endIf
endIf
endMethod
In the above example, the cMax method calculates the maximum value in the
Customer No field and 1 is added to it before assigning the value to the
newly inserted record.
Note: It is a good idea to turn off the Tab Stop property of the
field that is being incremented (in this case the Customer No field) so
that the user cannot change the sequence number.
To do this in Paradox 11, right-click the Customer No field object, choose
Properties, click the Run Time tab, uncheck Tab Stop, choose Apply and then OK.
The code works correctly whether the Tab Stop property is toggled on or off.
6. Check the syntax by pressing [F9] or check syntax icon of the toolbar and run the form by
pressing [F8] or run icon of the toolbar. If there are any syntax errors, compare your code
with the example closely.
With the form in run mode, the user can only insert records in edit mode by pressing
[Insert], choosing Record | Insert, or by ObjectPAL control.
In any of these cases, a new sequence number is generated and placed in the Customer No
field.
MULTIUSER AUTOINCREMENT ROUTINE
The preceding routine cannot be used in a multiuser environment. In order to get the
maximum value from a field, the cMax method must place a Write Lock on the table. A Write
Lock cannot be placed if other people are editing the table. The following example
demonstrates an autoincrement routine that works in a multiuser environment. The
AUTONUM table is used
to store the next number to be used when a new record is inserted.
1. Open the CUSTOMER and AUTONUM tables. Look at the last record in the
CUSTOMER table, add one to its Customer No and add that number to the AUTONUM table.
There should only be one record in the AUTONUM table. Close both tables.
2. From the Paradox Desktop, choose File | New | Form. Add the CUSTOMER
table from the Paradox samples directory to the data model.
3. Right-click the CUSTOMER table in the data model and remove the checkmark from the
Auto-Append property. This prevents the user from
http://kb.corel.com/scripts/texis.exe/kb/kb/+_wwFqw...MnDBa2d1BoDn5au5oDtaZxznqB7wcrzmevxwww/details.html (3 von 8)26.10.2003 18:06:39