I have a table with a pimary key consisting of two parts i.e. xxxYYY like where xxx is the three letter equipment type code i.e. DOZ and YYY is a numerical sequential number i.e. DOZ121
When I add a new record I wish to automatically number using to the same sequence i.e DOZ122
I need some help on the vba code, the equivalent in clipper would be something like
untested but shows the idea)
max=0
vtype="DOZ"
sele 1 'go to top of table
do while .not. eof()'scroll thru table
if substr(DATNo,1,3) = vtype
if val(substr(DATNo,4,3)) > max
max = val(substr(DATNo,4,3))
endif
endif
skip
loop
enndo
vDATNo=vtype&alltrim(str(max+1))
append blank
replace DATNo with vDATNo
i.e. loop thru the table looking for the higher DATNo for a specific type of equipment.
or can I do it with the the DMax command with some sort of string splitting as per the clipper example, or say a query with two new fields calculated for XXX and YYY
Thanks to anyone who can help me with the switch from clipper.
David
When I add a new record I wish to automatically number using to the same sequence i.e DOZ122
I need some help on the vba code, the equivalent in clipper would be something like
max=0
vtype="DOZ"
sele 1 'go to top of table
do while .not. eof()'scroll thru table
if substr(DATNo,1,3) = vtype
if val(substr(DATNo,4,3)) > max
max = val(substr(DATNo,4,3))
endif
endif
skip
loop
enndo
vDATNo=vtype&alltrim(str(max+1))
append blank
replace DATNo with vDATNo
i.e. loop thru the table looking for the higher DATNo for a specific type of equipment.
or can I do it with the the DMax command with some sort of string splitting as per the clipper example, or say a query with two new fields calculated for XXX and YYY
Thanks to anyone who can help me with the switch from clipper.
David