Windows 7
Access 2010
Extreme Novice
All,
I am trying to export a single query (qry_Change Control Forms) to multiple excel files based on the field "Business_Unit". Persons (field name "ID") can exist on multiple rows; all rows for a given ID will have the same Business_Unit value. I thought I could use an open query command but keep receiving an error. Here is what I have at the moment:
Code:
rs.Open "SELECT EMPLOYEE_ID_#, Business_Unit FROM qry_Generate Change Forms", cn, adOpenStatic, adLockPessimistic
While Not rs.EOF
DoCmd.OpenQuery "qry_Generate Change Forms", acViewNormal, acReadOnly, "EMPLOYEE_ID_#='" & rs!EMPLOYEE_ID_# & "'"
DoCmd.OutputTo acOutputQuery, "", acFormatXLS, "z:\2012_testing\ChgForms\" & Business_Unit & ".xls", False
DoCmd.Close acQuery, "qry_Generate Change Forms", acSaveNo
I am receiving an error on the following line that indicates "Wrong Number of Arguments or invalid property assignment"
Code:
DoCmd.OpenQuery "qry_Generate Change Forms", acViewNormal, acReadOnly, "EMPLOYEE_ID_#='" & rs!EMPLOYEE_ID_# & "'"
Any thoughts on what I am doing wrong? It is probably something very simple. I started with code I had that does this with a report to .pdf format and maybe that is where I am going wrong.
Kindest regards.
sren