TransferSpreadsheet - If empty do not export

S

StephanieH

I'm using TransferSpreadsheet to run several queries to a single spreasheet
so that each query has it's own tab in the spreadsheet. Sometimes, some of
the queries are empty. Is it possible to specify that if the query is empty,
do not export?
 
K

Klatuu

Dim rst As Recordset

Set rst = Currentdb.OpenRecordset("MyQueryName")

If rst.Recordcount < 1 Then
MsgBox "No Records For This Query"
Else
DoCmd.TransferSpreadsheet......
End If
 
Top