I have a "query by form" that returns a list of people, relevant data fields and their individual email addresses. From the form, I can specify several parameters to send to the query to retrieve specific data. I can then view, export to Word and Excel. This all works correctly.
I also have a need to directly email the people with their specific data from the query. I have searched the forums and found relevant code as shown below:
Public Function SendEmail() As Boolean
Dim olApp As Outlook.Application
Dim oMail As Outlook.MailItem
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim bodytxt As String
Dim docQuery As String
On Error GoTo HandleErr
Set db = CurrentDb
docQuery = "qryName"
Set rec = db.OpenRecordset(docQuery, dbOpenSnapshot)
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
etc., etc.
When I click the form button to send the email, the following error is returned:
3061:Too few paramters. Expected 2
I presumed that this was due to the parameter query since there are two paramters on the form that users can change. Removing all paramters from the query solved the problem. However, I need paramters so that I can email different data sets depending on selections on the form.
Any ideas would be greatly appreciated
Nigel.
I also have a need to directly email the people with their specific data from the query. I have searched the forums and found relevant code as shown below:
Public Function SendEmail() As Boolean
Dim olApp As Outlook.Application
Dim oMail As Outlook.MailItem
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim bodytxt As String
Dim docQuery As String
On Error GoTo HandleErr
Set db = CurrentDb
docQuery = "qryName"
Set rec = db.OpenRecordset(docQuery, dbOpenSnapshot)
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
etc., etc.
When I click the form button to send the email, the following error is returned:
3061:Too few paramters. Expected 2
I presumed that this was due to the parameter query since there are two paramters on the form that users can change. Removing all paramters from the query solved the problem. However, I need paramters so that I can email different data sets depending on selections on the form.
Any ideas would be greatly appreciated
Nigel.