I have a SQL Server routine that creates a table 3 times per day. All I want Access to do is Export the table all 3 times to Excel and email the Excel file to a number of recipients. I've been unable to test the email portion because the Export gives me an error in this subroutine
This is the error: Cannot update. Database or object is read-only. I'm not trying to update anything I just want to export the table to Excel
Code:
Public Sub Createfile()
Dim filename As String
On Error GoTo Err_Handler
Select Case Time
Case Is < #10:00:00 AM#
filename = "Daily_Referral_Spend_for_" & Format(Now() - 1, "mmddyyyy") & "_final_Run.xslx"
Case #10:00:00 AM# To #1:00:00 PM#
filename = "Daily_Referral_Spend_for_" & Format(Now(), "mmddyyyy") & "_Noon_Run.xslx"
Case Else
filename = "Daily_Referral_Spend_for_" & Format(Now(), "MMDDYYYY") & "_Evening_Run.xslx"
End Select
DoCmd.TransferSpreadsheet acExport, 8, "dbo_Auths_Daily_Report", filename, True
Exit_handler:
Exit Sub
Err_Handler:
MsgBox Err.Description
GoTo Exit_handler
Return
End Sub