The easiest way, although not the most efficient is something like
this.
In the on change event of the text box use dlookup. Syntax is:
DLookup(expr, domain, [criteria])
Assume you have a field in the db named "A" and that the field that
you do not want to duplicate is "B"
If isnull(DLookup("a", "tblName", "B = '" & me.mytext & "'" )) then
....
If the above is true you are Ok. If false then there is a dup.
If B is numeric remove the 2 single quotes.
The Domain Aggregate functions are great tools, especially if you are
not comfortable with code, although they can be less efficient than
other approaches.
Good Luck
Ira Solomon
On Sat, 17 Jan 2004 09:29:46 -0500, lost (AT) aol (DOT) com wrote:
Quote:
sorry for the basic question, but:
I have users entering a value on a form in a text box that is bounded
and called via a query. I need to check to see if there are any
duplicate values for that entry and bock it. I can't use the primary
key here, so I need some vb code to do the search the table.
I just need a place to start
Much thanks, |