I'm having difficulty finding any information about this particular issue. The only information I've found is that this seems to have been a bug in Access 2010 (I'm hoping that they fixed it for 2013 and that I'm simply ignorant of the solution).
I'm using the DoCmd.SendObject Method in access vba to send a report via email in outlook upon the on_click event for a command button. My code seems to work just fine and the email goes out as intended. The issue is that after running the code I'm unable to make any changes to the table that serves as the record source to the report, even though the report is closed. I get error 3211 "cannot lock record source because it is in use....."
I've removed the DoCmd.SendObject code and have no issues making changes to the tables and I don't receive the error. I am assuming that the method itself establishes some sort of link or connection between Outlook and the table.
So, my question is how to fix this. Is there VBA code that can terminate the link/connection between outlook and a table after using the DoCmd.SendObject Method?
To all,
I ended up using a different method for sending emails, which ultimately resolved all my issues and turned out to be more flexible than the SendObject method. Below is the code I used, hopefully you will find it useful:
(Just a note for others who find the code useful: I elsewhere used code to create a pdf file, which is why the pdf file name is a variable)
'Create a new e-mail and attach previously created pdf
Dim strLocation As String
Dim OutApp As Object
Dim OutMail As Object
Dim EmailTo As Variant
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
EmailTo = DLookup("Email", "tblTempProcessing")
With OutMail
.To = EmailTo
.CC = ""
.BCC = ""
.Subject = "Subject Text"
.Body = "Body Text"
.Attachments.Add ("C:\Folder\SubFolder\" & Variable & ".PDF")
.Send
End With
On Error GoTo 0