Hi Geof
Sorry I didnt convey right but the iPONo field is just for the user, internally I have the cID field in all the tables. cID char 8 length I dont mind if there are any missing.
I liked the idea of **lcPONum = CBNEWID("PURCHORD") **replace v_PO.PONO with lcPONum I havent tried it but I guess only when the user saves the record will the ID be increamented?
**This will then increment your POs in a human readable sequence. I still can read the Base16 ID where does that put me :-)
<i><font color="#663300">It is generally considered GOOD Practice to NOT use ID's that can be interpreted to have "meaning" by humans. In your case it seems that you are using the PO Number as an ID within your system.
I would recommend avoiding that practice.
Instead develop your system along these lines (Just a suggestion mind you!) Use CBNEWID() as the default value in the table to populate the cID/iid field as and when a new record is requested. Only use this number within the system. Users should not be aware of this number. Manually add a new record to the NextPK.dbf table. Set cKeyName to say "PURCHORD" and set the increment procedure to "IncrementBase10(...."
This will then increment your POs in a human readable sequence.
In the BeforeSave() method Add code something along the lines of: local lcPONum
lcPONum = CBNEWID("PURCHORD") replace v_PO.PONO with lcPONum
Do all your record identification within the system you are developing by using the cID/iID codes. Only use the PO Number at the point of interface between Human and Machine.
The advantage of this method is that you can afford to automatically assign and discard if need be many cID/iID numbers with little danger of running out of numbers and your system won't care if they have gaps. This is the CB Norm and no special tricks are needed.
Should you need to change the format of the PO numbers some time in the future, say adding the year as the last 4 chars of the PO number this can be readily accomodated.
Geof Whitham
<i><font color="#663300">Hi Everyone,
In my PO form I have a PO no which has a number autogenerated everytime a new PO is added. I had specified the default value CBNewID("PONO") in the view of the table and the Form show the next no. well. Now I have shifted the defauklt value CBNewID("PONO") into the Table using modify structure. Now the form has stopped showing the next no. and as soon as the record is saved it does get the assigned next no.
Is it possible/advisable to keep the CBNewID() in the Table and not in the view and if so how do I show the next no. in the form and yet provide for the user clicking Revert and the next no. not being wasted. </font></i>
</font></i>
Regards Bhavbhuti ©2001 Bhavbhuti Nathwani |