main logo
Subject: Re: Sequential Nos. (was BizObj Partiality to Default Values)
Author: Bhavbhuti Nathwani
Posted: 2001/11/20 09:04:40
 
View Entire Thread
New Search


Hi this is just what I did, Copied the CBNewID function and made the following changes:

Change 1:
FUNCTION VSONewID(tcAlias, tlNoUpdate)


Change 2:
*-* Commented Out 17/11/01 22:00:15
*-* If NoUpdate flag ignore REPLACE
IF NOT tlNoUpdate
*** EGL: 08/22/2000 - Just increment if type is Integer
IF NextPK.cType == "I"
* Cast to Integer type
luID = INT(VAL(luID))
REPLACE NextPK.cValue WITH PADL(TRANSFORM(luID + 1), NextPK.iMaxLength, "0")
ELSE
REPLACE NextPK.cValue WITH EVAL(NextPK.cIncrementProcedure)
ENDIF
ENDIF


In my form
Change 3:
Properties:
- Method:
- AfterNew:
LPARAMETERS tnRetVal

DODEFAULT()


THISFORM.txtiPONo.VALUE = VSONewID("IPONO", .T.)


RETURN tnRetVal
- BeforeSave:
DODEFAULT()


LOCAL liPONo

liPONo = VSONewID("IPONO", .T.)

IF THISFORM.txtiPONo.VALUE # liPONo
IF MESSAGEBOX("Purchase Order no. " + ;
TRANSFORM(THISFORM.txtiPONo.VALUE, "9999999999") + ;
" has now been assigned during your data entry session." + ;
CHR(13) + "Would you like to assign the next available no.", ;
4+32+0, "No. already assigned") = 6

THISFORM.txtiPONo.VALUE = VSONewID("IPONO")
ELSE
RETURN .F.
ENDIF
ENDIF


RETURN .T.



<i><font color="#663300">Hi all,

Getting inspiration from one of my previous threads this is what I have written for generating sequential nos. in a CB form. Please provide me with suggesstions however critical they may be, being a starter I will welcome experienced insights.

Properties:
- Method:
- AfterNew:
LPARAMETERS tnRetVal

DODEFAULT()


THISFORM.txtiPONo.VALUE = CBNewID("IPONO")
REPLACE NextPK.cValue WITH transform(THISFORM.txtiPONo.VALUE, " /at/ L 9999999999")



RETURN tnRetVal
- BeforeSave:
DODEFAULT()


LOCAL liPONo

liPONo = CBNewID("IPONO")

IF THISFORM .DO.T txtiPONo.VALUE # liPONo
REPLACE NextPK.cValue WITH TRANSFORM(liPONo, "@L 9999999999")

IF MESSAGEBOX("Purchase Order no. " + ;
TRANSFORM(THISFORM.txtiPONo.VALUE, "9999999999") + ;
" has now been assigned during your data entry session." + ;
CHR(13) + "Would you like to assign the next available no.", ;
4+32+0, "No. already assigned") = 6

THISFORM.txtiPONo.VALUE = CBNewID("IPONO")
ELSE
RETURN .F.
ENDIF
ENDIF


RETURN .T.


I feel that in true multi-users terms it may bomb out and I hate updating NextPK. How about the community proposing a function similar to CBNewID() but with the options similar to above usage.

I feel the need for sequential numbers is true and as far as my experience is concerned almost all my form have it. Internally I am still opting for cID but this is just for the user viewing satisfaction.
</font></i>

Regards
Bhavbhuti
 
©2001 Bhavbhuti Nathwani
<-- Prior Message New Search Next Message -->