Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop Macro on Null Query 1

Status
Not open for further replies.

ebizleads

Technical User
Sep 14, 2005
57
US
How do I write an expression to stop a macro if a query returns no records?

EB

 
EB
Your post doesn't indicate what the macro does.

Tom
 
How are ya ebizleads . . .

Something like this:
Code:
[blue]   Dim db As DAO.Database, rst As DAO.Recordset
   
   Set rst = db.OpenRecordset("[purple][b]QueryName[/b][/purple]", dbOpenDynaset)
   
   If Not rst.BOF Then
      [green][b]'Your Code Here[/b][/green]
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
It runs another macro that runs this code:

Function EPack()
On Error GoTo EPack_Err


DoCmd.OpenForm "Main Lead Console", acNormal, "SCEmail", "", , acHidden
DoCmd.OutputTo acOutputReport, "EPackage", acFormatRTF, "C:\MyDebtIQ\Packages\" & Forms![Main Lead Console].[ClientID] & "_" & Forms![Main Lead Console].[qlast] & "_" & Forms![Main Lead Console].[qfirst] & ".rtf"
DoCmd.OpenQuery "SendContract-Email-U", acViewNormal, acEdit



EPack_Exit:
Exit Function

EPack_Err:
MsgBox Error$
Resume EPack_Exit

End Function
 
. . . and this:
Code:
[blue]   Dim db As DAO.Database, rst As DAO.Recordset
   
   Set rst = db.OpenRecordset("[purple][b]SendContract-Email-U[/b][/purple]", dbOpenDynaset)
      
   If Not rst.BOF Then
      Something = [purple][b]EPack()[/b][/purple]
   End If

   Set rst = Nothing[/blue]



Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top