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!

How do I programatically check if a certain value exists in a tafield? 1

Status
Not open for further replies.

VBAguy22

IS-IT--Management
Aug 5, 2003
180
CA
Hello there,
I have a table containing shipping info for products. I need to, using VBA, check if product "X" exists in the PRODUCT field of this table. How do I do it?

For example, given table:

PRODUCT QUANTITY
A 10
B 14
C 9

I need a function to output true if I am looking for product name B and false if i am looking for product D

Thnx
 
Hi,

Just use DLookup and IsNull together:

Code:
Function DoesRecordExist (strProduct As String) As Boolean
 DoesRecordExist = Not IsNull (DLookup ("Product", "Products", "Product='" & strProduct & "'"))
End Function

John
 
I ran into another problem trying to run this code:
It worked fine for strings
Now instead of Product field I want to do the same for myDate field, which is of type Date.
Doesnt work anymore:(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top