G
Ginger
I have 2 "INSERT INTO" statements as shown below. I have a
recordset that opens and the code loops through the records
one at a time. Problem is that the one from the employee
file does work, and the one from the manager file errors
out. Can anyone see what syntax mistake I've made on the
first statement for the managers? I've looked and looked
and still don't see it.
What I'm trying to do is have a report containing only the
data necessary for each record be sent to that person by email.
Thank you in advance!
Ginger
This is the one from the manager file
qry1 = "INSERT INTO tbl_Monthly_File_Email_Branch (branch,
manager, [Email Address])"
& "SELECT tbl_incentive.org_code, tbl_orgcode.manager,
tbl_orgcode.email" _
& " FROM tbl_orgcode INNER JOIN tbl_incentive ON
tbl_orgcode.org_code = tbl_incentive.org_code" _
& WHERE ((tbl_orgcode.org_code) = """ & rs!OrgCode & """)" _
& " AND tbl_orgcode.email Is Not Null" _
GROUP BY tbl_incentive.orgcode, tbl_orgcode.manager,
tbl_orgcode.email"
DoCmd.RunSQL (qry1)
This is the one from the employee file
qry1 = "INSERT INTO
tbl_Monthly_File_Email_Employee(OrgCode, SSN, Employee,
[Email Address])"
& "SELECT tbl_incentive.org_code, ssn, emp_name, email" _
& " FROM tbl_incentive INNER JOIN tbl_emp_master ON
(tbl_incentive.org_code) = tbl_emp_master.org_code" _
& WHERE ((tbl_emp_master.ssn) = """ & rs!ssn & """)" _
& " AND tbl_emp_master.email Is Not Null" _
GROUP BY tbl_incentive.orgcode, tbl_emp_master.ssn,
tbl_emp_master.emp_name, tbl_emp_master.email"
DoCmd.RunSQL (qry1)
recordset that opens and the code loops through the records
one at a time. Problem is that the one from the employee
file does work, and the one from the manager file errors
out. Can anyone see what syntax mistake I've made on the
first statement for the managers? I've looked and looked
and still don't see it.
What I'm trying to do is have a report containing only the
data necessary for each record be sent to that person by email.
Thank you in advance!
Ginger
This is the one from the manager file
qry1 = "INSERT INTO tbl_Monthly_File_Email_Branch (branch,
manager, [Email Address])"
& "SELECT tbl_incentive.org_code, tbl_orgcode.manager,
tbl_orgcode.email" _
& " FROM tbl_orgcode INNER JOIN tbl_incentive ON
tbl_orgcode.org_code = tbl_incentive.org_code" _
& WHERE ((tbl_orgcode.org_code) = """ & rs!OrgCode & """)" _
& " AND tbl_orgcode.email Is Not Null" _
GROUP BY tbl_incentive.orgcode, tbl_orgcode.manager,
tbl_orgcode.email"
DoCmd.RunSQL (qry1)
This is the one from the employee file
qry1 = "INSERT INTO
tbl_Monthly_File_Email_Employee(OrgCode, SSN, Employee,
[Email Address])"
& "SELECT tbl_incentive.org_code, ssn, emp_name, email" _
& " FROM tbl_incentive INNER JOIN tbl_emp_master ON
(tbl_incentive.org_code) = tbl_emp_master.org_code" _
& WHERE ((tbl_emp_master.ssn) = """ & rs!ssn & """)" _
& " AND tbl_emp_master.email Is Not Null" _
GROUP BY tbl_incentive.orgcode, tbl_emp_master.ssn,
tbl_emp_master.emp_name, tbl_emp_master.email"
DoCmd.RunSQL (qry1)