cabete,
I can't open your database (Unrecognized database format) but,
Left("A.01.DEC.0004.011.015",18) = A.01.DEC.0004.011. (DwgBase)
Right("A.01.DEC.0004.011.015",3) = 015
CInt(Right("A.01.DEC.0004.011.015",3)) = 15
CInt(Right("A.01.DEC.0004.011.015",3)) + 1 = 16
Format(CInt(Right("A.01.DEC.0004.011.015",3)) + 1,"000") = 016 (NextNum)
So, give a try to this query on your table with the drawing codes:
Code:
SELECT Left([dwg],18) AS DwgBase,
Format(Max(CInt(Right([dwg],3)))+1,"000") AS NextNum
FROM tblDwg
GROUP BY Left([dwg],18);
(copy and paste the SQL code above into a new query in SQL view and save it as qryNextNums)
dwg: The field with drawing code (A.01.DEC.0004.011.015).
Replace it with the actual name of the field.
tblDwg : The table with drawing codes.
Replace it with the actual name of your table.
So, if a field with the name txtDwg contains the code A.01.DEC.0004.011.015, the next drawing code of A.01.DEC.0004.011. is:
Code:
Left([txtDwg],18) & nz(DLookup("NextNum","qryNextNums","DwgBase='" & left([txtDwg],18) & "'"),"000")
Cheers,
John