sub fieldname beforeupdate (cancel as integer)
dim maxlen as integer
[COLOR="Red"]'assume the length is 11[/COLOR]
maxlen=11
[COLOR="red"]'but its 12 in these circumstances[/COLOR]
if left(nz([fieldname],vbnullstring),3)="yor" then maxlen = 12
[COLOR="red"]'so how long is it?[/COLOR]
if len(nz([fieldname],vbnullstring))>maxlen then
msgbox("Too long")
[COLOR="red"]'in which case, this prevents the change being accepted[/COLOR]
cancel = vbcancel
exit sub
end if
end sub