Testing if a query has a result

  • Thread starter mw4 via AccessMonster.com
  • Start date
M

mw4 via AccessMonster.com

I have a (vehicle Identification Number) VIN field that has 17 digits in it.
I have a shortcut search that uses the last 8 of the VIN and a Car's Make to
do a lookup.

SOMETIMES there are duplicates of the last8 & Make and what I'd like to do is
return a query with the the duplicated Last 8's, but only if there are any (0.
001% of the time).

(No dupes process)
1. Click on button
2. Query A runs to check for dupes (since none, user gets no prompt at all)
3. Query B runs

(Dupes Process)
1. Click on button
2. Query A runs and returns the list of dupes.
3. Process is stopped here in order to input manually.
4. Query B DOES NOT RUN


My code is now set up to click on button and run the query.

This is a query to determine if there are last8's with more than 1 VIN:

SELECT qryLocLast8Lookup.Last8, Count(qryLocLast8Lookup.Vin) AS CountOfVin
FROM qryLocLast8Lookup LEFT JOIN tblOrders ON qryLocLast8Lookup.PoNum =
tblOrders.PoNum
GROUP BY qryLocLast8Lookup.Last8
HAVING (((Count(qryLocLast8Lookup.Vin))>1))


so in essence IF a record exists in this query above, show it and stop, ELSE
do normal


IF

** there are records in Query Result from Query A
** show query results from Query A

else

**Run Query B

ENDIF


Can someone help me set this up so I can test for the existance of records in
query result A.
That's the piece that I don't know how to do.
 
M

mw4 via AccessMonster.com

I went with this:

If DCount("*", "queryA") > 0 Then

Dim stDocName As String
stDocName = "queryA"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Else

Dim stDocName As String
stDocName = "queryB"
DoCmd.OpenQuery stDocName, acNormal, acEdit

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top