this can be done with zero programming. Set the date field to date/time ,
with default = now()
format = General Date
the records can now be ordered in time order. It does not start at 1 like your example but it is equivalent with zero programming.
if you want to use vba:
Now when you need to make a new work order for a new day,
get the MAX value for THAT date,
then either start from 1 (if null) or add +1 if this day exists:
btnAddNewOrder_click()
dim vDate, vRet, vNum, vOrder
dim i as integer
vDate = clng(date)
vRet = DMax("[RWO]","qsDateVals","[DateVal]=" & vDate) 'find the max entry for the day
if isNull(vRet) then
vOrder = vDate & "-01"
else
i = instr(vRet,"-")
vNum = mid(vRet,i+1)
vNum = val(vNum) + 1
vOrder = vDate & "-" & format(vNum,"00")
endif
txtOrderNum = vOrder 'fill in new order# in the textbox
end sub
make a query to pull the [RWO] and the bare date values in the RWO. (left 5, no day#)
in the query: qsDateVals,
SELECT [RWO],(Left([RWO],5)) AS DateVal FROM tData;
Bookmarks