Evaluating a query prior to outputting to a file

  • Thread starter Thread starter Kathie G via AccessMonster.com
  • Start date Start date
K

Kathie G via AccessMonster.com

Hello all,

If I am exporting a query but want to evaluate the query for data first -
how would I do this? IE: If it is blank - return an error stating no date
available?

Thanks,
Kathie
 
When you say "exporting a query", are you running an update query, or is this
perhaps a make-table query or the record source of a report?

If it is an action query (make-table or update), make an identical
non-action query that has the same criteria but is just a select query. Then
add this code when you run your query:

Private Button1_Click()
If DCount("[Field1]","[Query1]") = 0 then
MsgBox "There are no records."
Else
DoCmd.OpenQuery "Query2"
End If
End Sub

This will count the number of records to be returned and generate the
message if there are none. If Query1 is just a select query (i.e. basis of a
report, etc.), then use Query1 for both the DCount and the DoCmd...
 
Back
Top