Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding matches in a table

Status
Not open for further replies.

hysaccess

Programmer
May 27, 2003
12
AU
Hello,

I would just like to ask what is the simplest way to check if there is already a match in the table.

E.g.

I currently have a simple table containing a list of filenames.

and i just simply want to know whether a filename already exists in that table already..

 
Are you entering the filename into a form? Is the form bound to the table in question?

If the answer to both is YES, then try putting the following into the BeforeUpdate event of the filename textbox on the form:

Me.RecordsetClone.FindFirst "Filename = '" & Me.txtfilename & "'"
If Not Me.RecordsetClone.NoMatch Then Msgbox Me.txtfielname & " is already in the table!"

This assumes that the control on your form is named txtfilename and the field on the table is named Filename.

[shadeshappy] Cruising the Information Superhighway
(your mileage may vary)
 
I'm a little confused as to wat you are trying to accomplish...

But I will giva an example that I think is what you are looking for:

You have a table called tblItems in it are two fields, ID and Filename

You enter a Filename into a textbox and have the AfterUpdate Event check to see if the filename already exists:

Dim rsFNm as Variant

rsFNm = DLookUp("[FileName]","tblItems","[Filename] = '" & me.TextboxName & "'"

If isNull(rsFNm) or rsFNm = "" then
Else
Msgbox "File Already exists",vbOkOnly, "File Check"
End If



"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top