platypus71
Technical User
I have a Function SendEmail(strTo, strMessage, strAttach, strSubject, strBCC) defined and works just fine.
I have previously created functions that ran against the SendEmail function and they have worked just fine. I have since written the following Function and am getting an error and don't understand why.
The error I get is Run-time error '3061': Too few parameters. Expected 1.
The only lines that have changed from previous functions are the lines that start with sqlstr, sbj, bod, and writelog.
Any help would be appreciated.
I have previously created functions that ran against the SendEmail function and they have worked just fine. I have since written the following Function and am getting an error and don't understand why.
Code:
Function PostTests()
Dim X As Boolean
Dim mydb As Database
Dim rst As Recordset
Dim sqlstr As String
Dim writelog As String
Dim sbj As String
Dim bod As String
Dim MailType As String
TestType = "Post"
sqlstr = "SELECT tblTestURL.URL, tblPerfManageTest.Name, tblPerfManageTest.NotesID, tblPerfManageTest.TestName, tblPerfManageTest.TestType, tblPerfManageTest.ClassDate, tblPostTestsLog.TestType FROM tblPerfManageTest LEFT JOIN tblPostTestsLog ON (tblPerfManageTest.NotesID = tblPostTestsLog.NotesID) AND (tblPerfManageTest.TestName = tblPostTestsLog.TestName)WHERE (((tblPerfManageTest.TestType) Like 'Pre') AND ((tblPostTestsLog.TestType) Is Null));"
Set mydb = CurrentDb
Set rst = mydb.OpenRecordset(sqlstr)
Do While Not rst.EOF
sbj = "Post Test for " & rst!TestName & ""
bod = "Dear " & rst!Name & vbCrLf & "Please take a few minutes to complete our Post test for the " & rst!TestName & " class you recently attended. You can get to the online test by going to " & rst!URL & "." & vbCrLf & vbCrLf & "Thank you!" & vbCrLf & "Luigi"
X = SendEmail(rst!NotesID, bod, "", sbj, "")
writelog = "INSERT INTO tblPostTestsLog( NotesID, TestType, TestName ) IN 'J:\Databases\Training.mdb' VALUES('" & rst!UserID & "','" & TestType & "', '" & rst!TestName & "')"
DoCmd.RunSQL writelog
rst.MoveNext
Loop
End Function
The error I get is Run-time error '3061': Too few parameters. Expected 1.
The only lines that have changed from previous functions are the lines that start with sqlstr, sbj, bod, and writelog.
Any help would be appreciated.