Hi, my name is Scott, and this is my first request for help in this, or any forum.
I've been using Access for many years, but have only recently begun using VBA. This forum has been a great source of information for me. I have found answers to almost every question I've had here. However, I haven't been able to find anything that helps me with my current issue.
I have written an Access 2013 database that produces invoices for about 100 customers each month. The invoice data is compiled in a table (tbl Invoices) which generally has around 150 records.
The database is in a shared Dropbox folder. There are three users, but only one user is in the database at a time.
A report (Current Invoices) creates an invoice for each client in the table. Each invoice can be emailed separately by clicking a button on the invoice as it's being reviewed.
The code I've written is below. It has been working fine since I wrote it a couple months ago. It creates a client-specific version of the invoice then uses DOCMD.SENDOBJECT to send a PDF version of that invoice to the client. The body of the email varies based on whether or not the client pays via EFT, or not.
Finally, it updates the record in tbl Invoices to let the user know the invoice has been sent.
Yesterday, the process stopped working for all three users. When I remove the error handling, we get an error 2046 - 'The command or action "SendObject' isn't available now.'
I have not been able to find any reason for the command to stop working.
I installed Access Runtime 2013 on my computer since the last time it worked. None of the other users made any changes to their computer.
I would welcome any help or advice.
I've been using Access for many years, but have only recently begun using VBA. This forum has been a great source of information for me. I have found answers to almost every question I've had here. However, I haven't been able to find anything that helps me with my current issue.
I have written an Access 2013 database that produces invoices for about 100 customers each month. The invoice data is compiled in a table (tbl Invoices) which generally has around 150 records.
The database is in a shared Dropbox folder. There are three users, but only one user is in the database at a time.
A report (Current Invoices) creates an invoice for each client in the table. Each invoice can be emailed separately by clicking a button on the invoice as it's being reviewed.
The code I've written is below. It has been working fine since I wrote it a couple months ago. It creates a client-specific version of the invoice then uses DOCMD.SENDOBJECT to send a PDF version of that invoice to the client. The body of the email varies based on whether or not the client pays via EFT, or not.
Finally, it updates the record in tbl Invoices to let the user know the invoice has been sent.
Yesterday, the process stopped working for all three users. When I remove the error handling, we get an error 2046 - 'The command or action "SendObject' isn't available now.'
I have not been able to find any reason for the command to stop working.
I installed Access Runtime 2013 on my computer since the last time it worked. None of the other users made any changes to their computer.
I would welcome any help or advice.
Code:
Function EmailInvoice(ClientID, EFT As Boolean, Address As String)
Dim Body As String
Dim Subject As String
Subject = "Invoice from Company Name"
On Error GoTo Error_Happened
If EFT = True Then
Body = "Please see the attached invoice. Your account will be debited the invoiced amount on or around the 5th of the month." & _
Chr(11) & Chr(11) & "Please email with any questions." & _
Chr(11) & Chr(11) & "Regards," & _
Chr(11) & "Company Name"
Else
Body = "Please mail payment to the address on the attached invoice." & _
Chr(11) & Chr(11) & "Please email with any questions." & _
Chr(11) & Chr(11) & "Regards," & _
Chr(11) & "Company Name"
End If
DoCmd.OpenReport "Current Invoices", acViewPreview, , "ClientID = " & ClientID
DoCmd.SendObject acSendReport, "Current Invoices", acFormatPDF, Address, , , Subject, Body, True
' Sets Sent field to equal "Sent"
DoCmd.RunSQL "UPDATE [tbl Invoices] " & _
"SET [tbl Invoices].Sent = ""Sent"" " & _
"WHERE ((([tbl Invoices].ClientID)=" & ClientID & "));"
DoCmd.Requery Reports![tbl Review Invoices]
Error_Happened:
DoCmd.Close acReport, "Current Invoices", acSaveNo
End Function
Last edited: