I have this db and for automtic sending emil based on query to send asingle record to specific contact email
but I have a problem with SELECT with a message said ( too few parameters . expected1) i do not know how to solve that
Private Sub Command6_Click()
'Dim MYDB As Database, RST11 As Recordset, rstemp As Recordset, mto As String, empstring As String, sqlstring As String, memp As string, med As string
Dim MYDB As dao.Database, RST11 As Recordset, rstemp As Recordset, mto As String, empstring As String, sqlstring As String, mco As String, memp As String, med As String
Dim Qdf As QueryDef
Dim prm As Parameter
Set MYDB = CurrentDb
empstring = "SELECT distinct payroll,id FROM allownceQuery where id = id"
Set rstemp = MYDB.OpenRecordset(empstring, dbOpenDynaset)
rstemp.MoveFirst
While Not rstemp.EOF
memp = rstemp("payroll")
med = rstemp(id)
Set Qdf = MYDB.QueryDefs("allownceQuery")
sqlstring = "SELECT allownce1.payroll,personal.al-name,personal.field,allownce1.allawnce, allownce1.amount,"
sqlstring = sqlstring & " allownce2.date, allownce2.id,balance.balance FROM (((personal inner join allownce1 on personal.payroll = allownce1.payroll),"
sqlstring = sqlstring & " inner join allownce2 on allownce1.id = allownce2.id)"
sqlstring = sqlstring & " inner join balance on allownce1.payroll = balance.payroll)"
sqlstring = sqlstring & " WHERE personal.email like '*Khalda*' and personal.payroll = " & memp & " and allownce1.id = '" & med & "'"
sqlstring = sqlstring & " ORDER BY personal.payroll"
Qdf.SQL = sqlstring
Qdf.Close
'For Each prm In Qdf.Parameters
'prm.Value = Eval(prm.NAME)
'Next prm
Set RST11 = Qdf.OpenRecordset
RST11.MoveFirst
'While Not RST11.EOF
'combo_emp.RowSource = "SELECT EMPID,EMPNAME FROM employee WHERE COMPANY = '" & RST11("COMPANY") & "' AND EMPID = " & RST11("EMPID")
mto = RST11("email")
RST11.Close
DoCmd.SendObject acSendQuery, "allownceQuery", acFormatXLS, mto, , , " allowances added to payroll", "attached is your allowances payment", False
rstemp.MoveNext
Wend
MsgBox "EMAIL PROCESS COMPLETE", vbInformation
MYDB.Close
End Sub