Dmax Function

  • Thread starter Thread starter Raul Sousa
  • Start date Start date
R

Raul Sousa

I have this code:

If [TDocumento] = 1 Then
DocID = "VD" & Year(DataF)
varMax = DMax("DocID", "FacturaVenda", "DocID like """ & DocID & "*""")
varMax = Val(Nz(Mid(varMax, 7), 0)) + 1

my database arrived at DocID VD2008999. Then, with this code, it created
DocID VD20081000.
The problem is that, Now DocID is not increasing because the Dmax Function
is always returning VD2008999. For this function VD2008999 > VD20081000.

How can I solve this situation?
 
VD2008999 IS always greater than VD20081000.

Try:

varMax = DMax("Mid(DocID, 7)", "FacturaVenda", "DocID like """ & DocID &
"*""")
 
Back
Top