dbTalk Databases Forums  

Searching Table

comp.database.ms-access comp.database.ms-access


Discuss Searching Table in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
lost@aol.com
 
Posts: n/a

Default Searching Table - 01-17-2004 , 08:29 AM






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,


Reply With Quote
  #2  
Old   
Ira Solomon
 
Posts: n/a

Default Re: Searching Table - 01-17-2004 , 01:41 PM






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,


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.