hello Rudner . . .
try this code :
----------------------------------------------------
Function Existence(Byval iNdx$,Byval iData$) as Boolean
rc.Open "SELECT [" & INdx & "] FROM PRODUCTS WHERE [" & iNDX & "]='" & IData & "'"
if Not Rc.EOF then
Existence = True
end if
End Function
-----------------------------------------------------
To Use it :
If Existence("YOUR PRIMARY FIELD","VALUES FROM CONTROLS") then
msgbox "DUPLICATE DATA",,"ZERO ICE"
exit sub
end if
-----------------------------------------------------
that's all. And if you put new parameter as Recordset you'll be able to check all primary in a table just with this function.
bye . . . and happy coding !!!!!!!
|