Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WIZARD FORM auto-increment key field

Status
Not open for further replies.

vfp5

Programmer
Oct 17, 2001
14
0
0
US
s-)
EXISTE ALGUN ASISTENTE QUE CREA UN FORM EN VFP CON auto-increment key field COMO LO HACE MS-ACCESS.

 
If what you are asking is how to add an auto increment key field to a form created by the form wizard, this is what I have done before. Add the following to the cmdAdd.Click() method (changing the table, field, and text box names of course):

* cmdAdd.Click()
lcOldDeleted = SET("DELETED")
SET DELETED OFF
* Must do this before the DODEFAULT(); it must move the record pointer.
CALCULATE MAX(requestor.nrequestor) TO lnmaxid
SET DELETED &lcOldDeleted

DODEFAULT() && Runs parent class code.

* Only set if value is 0. It was getting incremented twice.
IF THISFORM.txtnRequestor.Value = 0
THISFORM.txtnRequestor.Value = lnmaxid + 1
ENDIF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top