Selasa, 06 Maret 2012

Re: [MS_AccessPros] Duplicates in a field

 

Hi Katrina -
I got this from Crystal several years ago, I was using this to check and see if a Name was in the database before adding or trying to add a name.
 
This could go in the after update event perhapse to check and see if the case number exist
 
 
here is one way:
'~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~ ~~~
dim strSQL as string
dim rst as dao.recordset
strSQL = "SELECT * FROM Tablename WHERE <criteria you are checking>"
set rst = currentdb.openrecordset(strSQL, dbopensnapshot)
if NOT rst.eof then
   ' value is already there
end if
rst.close
set rst = nothing
'~~~~~~~~~~~ ~~~~~~~~~ ~~~~~~~~~ ~~~
in your criteria, make sure you include that the record ID <> the one you are on … same as for next method

Take care,
Michael

From: ka0t1c_ang3l <no_reply@yahoogroups.com>
>To: MS_Access_Professionals@yahoogroups.com
>Sent: Tuesday, March 6, 2012 9:09 AM
>Subject: [MS_AccessPros] Duplicates in a field
>
>

>Hello everyone!
>
>I'm creating a new database for our Public Safety Department. In my database I have a Citation Number that is issued. Is there a way to code this field to prompt me that the number entered has already been used to avoid duplicate numbers being issued?
>
>Any help is appreciated!
>
>Thanks!
>
>Katrina
>
>
>
>
>

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar