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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordsets - NoMatch 1

Status
Not open for further replies.

SiJP

Programmer
May 8, 2002
708
GB
I have some issues with using recordsets that you may be able to help out on. Heres my senario:


form: frmStock
table: tblStock
table: tblProducts

On my (stock) form I have the ability to search for a product from the product table. Once I have returned the product value (eg Product Code) I can add it to the tblStock with other data such as inventory details etc.

I also have the ability to enter the product code directly into a field on the frmStock so that if the user knows the number, it will save him/her looking it up (its a time saving thing...).

I have written a small section of code to check to see if that manually typed code actually exists in my products table, and if it doesn't then to produce an error message. This is my code:

Code:
Function fProductCodeCheck()

Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tblProducts", dbOpenDynaset)


rst.MoveFirst
rst.FindFirst "ProductCode=" & txtProductCode 'ProductCode is the field on the table, txtProductCode the field on my form

If rst.NoMatch Then
    MsgBox "Not found"
Else
    MsgBox "Found 1 record: " & rst.Fields("Description") 'Description is a field within the tblProducts
End If
rst.Close

End Function

Its quite bizzare in the fact that even if I type a correct code into txtProductCode (i.e. the relating product exists in my table), I sitll have the result "Not Found" returned. Is there a problem with my code? I'm not that familiar with using recordsets so more than likely there will be issues!

TIA
 
What data type is ProductCode in the table?

There are two ways to write error-free programs; only the third one works.
 
I think that questions answers mine.. its Text!

Table is linked via ODBC to a sequel back end, and these tables are managed by someone else..

I'm assuming thats my problem?!
 
Okay so what you need is...

rst.FindFirst "ProductCode = '" & txtProductCode & "'"

That should do it (fingers crossed)

There are two ways to write error-free programs; only the third one works.
 
Hey, what'dya know.. it worked!!

Thanks for understanding and helping - much appreciated!
 
No problem.

[thumbsup2]

There are two ways to write error-free programs; only the third one works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top