Check to see whether a table contains a set of fields already

  • Thread starter Thread starter tryit
  • Start date Start date
T

tryit

Let's say I have a table that has five fields, a, b, c, d, and e

For any given values of a,b,c (say a=1,b=2,c=3), I'd like to check
whether any records in the table already have those values for those
fields.

For example:

If my table looks like

a,b,c,d,e

1,2,3,4,5
2,3,4,5,6
3,4,5,6,7
4,5,6,7,8
etc.

Then, the first record would be a "match" with a=1,b=2,c=3.

How do I test for that?

TIA,
Tom
 
John said:
Thank you, but I wasn't looking for SQL code. I was looking for VBA
code that will return true or false. Is there a way to test in VBA
code whether a query is empy or not?


Since the data is in a table, you need to use a query to see
it. You may find if more convenient to use a Domain
Aggregate function (that creates and runs an equivalent
query for you):

If DCount("*", "table". "a=1 And b=2 And c=3") > 0 Then

If that's not what you want, then you can open a recordset
on the query and check its RecordCount property.
 
Back
Top