Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Auto Generated ID number codes
Message
 
À
18/08/2006 16:52:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01146881
Message ID:
01146885
Vues:
20
>I already had a program that has an auto-generated ID . I used a textbox and whenever I click the new button I use this commands:
>
>
>
>    LOCAL liMatic
>
>     liMatic = TableName.Idno + 1
>
>     APPEND BLANK
>
>     ThisForm.txtIdNo.Value = liMatic
>
>     ThisForm.Refresh()
>
>
>This commands does work to automatically generate an ID number with an Integer Value. My problem right now is that I used a combo box and the ID number was change to character value because I need to have an ID like RL0001 , RL0002 , RM0001. In my form there are two combo boxes. the 1st is for the ID and the 2nd is for choosing whether it is a ROLL or a REAM. If I choose ROLL then Save I must have an ID number of RL0001. Its hard to generate an auto-generated ID using a combo box and as a character value. Can u please sirs help me with this problem? thank you so much .
 LOCAL lcMatic
 LOCAL lcComboValue
 lcComboValue = IIF(thisform.ComboBoxName.Value==[ROLL],[RL],[RM])
 SELECT MAX(VAL(SUBSTR(Idno,3))) FROM TableName WHERE LEFT(Idno,2) == [lcComboValue] INTO ARRAY laId
 IF _TALLY == 0
    lcMatic = lcComboValue + [0001]
 ELSE
    lcMatic = lcComboValue + PADL(ALLTRIM(STR(laId[1]+1)),4,[0])
 ENDIF
 APPEND BLANK
 ThisForm.txtIdNo.Value = liMatic
 ThisForm.Refresh()
not tested and I am almost asleep so be carefull :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform