Exit Sub

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I have a form with some vb behind that downloads data from
a program that houses sales data at 5 AM every morning.
Sometimes the connection to that other program fails but I
don't realize it until I get to work. The problem is that
I have some other procedures that automatically emails
reports out to people at 6,7,8, and 9 AM based on that
data, so if the connection fails, the reports are wrong.

What I'd like to do is check the data table that is
downloaded prior to sending the 6AM reports to see if any
of the invoice dates are from the previous day. If so,
then exit the sub procedure altogether and send an alert
to my phone. I know how to send the alert but I'm not
exactly sure about how to look up the dates. Here's what
I'm thinking:

tblShipped is the table that contains the downloaded data.
InvoiceDate are shipments of product

If DMax("[InvoiceDate]","[tblShipped]") <> Date()-1 Then

DoCmd.SendObject acSendNoObject, , ,
MySMSAddress, , , "Failure Alert", "Connection to the
sales database failed.", False

DoCmd.Quit acQuitSaveNone

End If
 
Back
Top