I had some additional work to be completed and finished that... now I am having a whole new issue; "Run-Time Error 3061". The highlighted line is: Set rec = CurrentDb.OpenRecordset(strQry)
Explain what I am trying to do.
Form: "Employee Voucher" has a combobox "Combo0" that the user will select a persons name. Then they click Command Button 3 to run the Query and View the Report.
Code:
DoCmd.OpenQuery "Query2", acViewNormal, acEdit
DoCmd.OpenReport "Voucher", acViewReport, , , acWindowNormal
Query: "Query2" is a simple query to look up the information to pass to the Report
Code:
SELECT Oracle.[Resource Name], Oracle.[WO Invoice], Oracle.[Piece Rate Total], Oracle.[Rate %], Oracle.Hours, Oracle.[Avg Hourly rate], Oracle.[Visit Date], Oracle.[Invoice Date], Oracle.[Employee ID], Oracle.[Store ID], Stores.[City, ST], tblRoster.Email AS AssemEmail, Right(Trim([Assembler]),Len(Trim([Assembler]))-InStr(1,[Assembler]," ")) AS [First]
FROM tblRoster INNER JOIN (Stores INNER JOIN Oracle ON Stores.[Store #] = Oracle.[Store ID]) ON tblRoster.EmployeeID = Oracle.[Employee ID]
WHERE (((Oracle.[Employee ID])=[Forms]![Form1]![Combo0]));
Report:"Voucher" Displays the aforementioned query, and where I click the command button to execute the email. The line I highlighted in Red is where the error is occuring
[CODE][Private Sub Command33_Click()
'Public Sub NewEmail()
Dim olApp As Object
Dim olItem As Variant
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim strQry As String
Dim aHead(1 To 8) As String
Dim aRow(1 To 8) As String
Dim aBody() As String
Dim lCnt As Long
Dim eRow As String
'Create the header row
aHead(1) = "Visit Date"
aHead(2) = "Invoice Date"
aHead(3) = "Store ID"
aHead(4) = "City, ST"
aHead(5) = "Hours"
aHead(6) = "Rate %"
aHead(7) = "Piece Rate Total"
aHead(8) = "WO Invoice"
lCnt = 1
ReDim aBody(1 To lCnt)
aBody(lCnt) = Me.First & "," & "<br>" & "If you earned Incentive or Premium Pay this pay period as defined in the Assembly Compensation Memo, due to timing of this communication, it will not be reflected on your payroll voucher below; but can be seen in Oracle on your applicable pay slip." & "<br>" & "<br>" & "<i>" & "If you have questions regarding this voucher ONLY, please reply to this message, or call (111)111-1111. Please note, a response will NOT be provided for questions unrelated to this voucher." & "<br>" & "For questions regarding mileage, piece rate, incentive pay/bonuses, Direct Deposit, etc., please contact your manager, or refer to your Assembly Manual." & "</i>" & "<br>" & "<br>" & "<HTML><body><table border='2'><tr><th>" & Join(aHead, "</th><th>") & "</th></tr>"
'Create each body row
strQry = "SELECT * From Query2"
Set db = CurrentDb
Set rec = CurrentDb.OpenRecordset(strQry)
If Not (rec.BOF And rec.EOF) Then
Do While Not rec.EOF
lCnt = lCnt + 1
ReDim Preserve aBody(1 To lCnt)
aRow(1) = rec("Visit Date")
aRow(2) = rec("Invoice Date")
aRow(3) = rec("Store ID")
aRow(4) = rec("City, ST")
aRow(5) = rec("Hours")
aRow(6) = Format(rec("Rate %"), "#%")
aRow(7) = Format(rec("Piece Rate Total"), "Currency")
aRow(8) = Format(rec("WO Invoice"), "Currency")
aBody(lCnt) = "<tr><td>" & Join(aRow, "</td><td>") & "</td></tr>"
rec.MoveNext
Loop
End If
aBody(lCnt) = aBody(lCnt) & "</table></body></html>"
'create the email
Set olApp = CreateObject("Outlook.application")
Set olItem = olApp.CreateItem(0)
'olItem.display
olItem.To = [Voucher].[AssemEmail]
olItem.CC = ""
olItem.Subject = "Assembly Piece Pay Voucher Statement - " & Date
olItem.htmlbody = Join(aBody, vbNewLine)
olItem.display
End Sub
/CODE]
When I view the Query there are records, as well as in the Report. So I cannot figure out why it states the "Run-Time Error 3061: Too few parameters. Expected 1"
Appreciate your help/input