all I need to figure out is how to override the error message
that access provides with incorrect data with my own validation text
(it's ignoring anything put in the form validation).
Use the OnBeforeUpdate event:
private sub txtStartNumber_BeforeUpdate(cancel as integer)
dim errorMessage as string
if isNull(txtStartNumber.Value) then
' missing values, no good
errorMessage = "Please make sure you fill in a number!"
elseif not isnumeric(txtStartNumber.Value) then
' have to be a decent number
errorMessage = "Doh! Please make it a proper number."
elseif (cInt(txtStartNumber.Value) mod 50)<> 1 Then
errorMessage = "It must be something times fifty plus one"
else
' must be okay
errorMessage = ""
end if
if len(errorMessage) > 0 Then
' display the error
msgbox errorMessage, vbExclamation, "Start Number error"
' and refuse the update
Cancel = True
else
' this is unneccessary, but you see the point
Cancel = False
End if
End Sub
As for the startnumber field, yes it is a (double)
numeric field.
Ugh! Why not an integer or a long? There is a chance that 6801 can
6800.99998 depending on where the number comes from. Integers are smaller
and faster too.
Hope that helps
Tim F