VBA to skip Query

  • Thread starter Thread starter Steven M. Britton
  • Start date Start date
S

Steven M. Britton

I have a select query that makes a file that I use a
transfertxt command to make a CSV file for my customer. I
then have some code that takes the CSV file and
automatically emails that file to my customers.

My question or problem is, if the query come back with no
records it still exports the file and it's blank. What I
want to do is an if else or something that would skip that
section of code if the query returns no records. Any
ideas?

-Steve
 
Steve,
After the line executing the code to run the query, insert
code resembling this into your module:

If YOURQUERY.BOF And YOURQUERY.EOF Then
YOURQUERY.Close
Exit Function

Hope this helps,
Dave
 
How about:

If DCOUNT("some field", "yourQuery") > 0 then
'insert your transfertext and email code here
EndIf

HTH
Dale
 
Back
Top