View Full Version : Macro to check first instance of a number


colin4255
10-27-2003, 04:18 AM
I have a field on a form that we enter a 4 or 6 digit specification number into each time the form is filled in.

What I need is, having entered the number, have access check all the other records in the table that field is form and tell me if the number I have entered is a new one, in other words, if there is no other instance of it in the underlying table/query.

Any simple suggestions. I am no good at writing code.

Fuga
10-27-2003, 05:29 AM
I think you can use this as an after update event.

dim sSpec as string

sSpec = me.yourfield
if dcount("yourfield","yourtable","yourfield=" & sSpec) = 0 then
msgbox ("this is a new number")
end if

I havenīt tested it though.

Fuga.