Export Subform Results to Excel

K

KC_Cheer_Coach

I have a search form where the user will choose data via drop downs before
hitting the "view" button, which displays the results in a subform. I have to
be able to hit the "export" button and send only the results displayed on the
subform to excel. I have been all over the internet, my Access 2003 book, and
the MS Communities trying almost everything I have come across.

I ended up creating a qry that will pull in the data from the main form
based on what the user chose. The problem is that if the user doesn't choose
anything, the qry returns one blank row. I modified the qry to encompass the
possibility of nothing being chosen and now I receive a msg that the
expression is too complex to be evaluated. I can export the results of the
qry to excel, but I am unable to build the qry. Am I on the right track? This
is what I have right now:

SELECT tblAllRuns.[RUN NBR], tblAllRuns.SYSTEM, tblAllRuns.CYCLE,
tblAllRuns.TASK, tblAllRuns.ASSIGNEE, tblAllRuns.VALUE, tblAllRuns.HOURS,
tblAllRuns.MIN, tblAllRuns.TOTAL
FROM tblAllRuns
WHERE ((((tblAllRuns.[RUN NBR])=[Forms]![frmReports]![cboRun]) OR
((tblAllRuns.[RUN NBR])="")) AND
(((tblAllRuns.SYSTEM)=[Forms]![frmReports]![cboSystem]) OR
((tblAllRuns.SYSTEM)="")) AND
(((tblAllRuns.CYCLE)=[Forms]![frmReports]![cboCycle]) OR
((tblAllRuns.CYCLE)="")) AND
(((tblAllRuns.TASK)=[Forms]![frmReports]![cboTask]) OR
((tblAllRuns.TASK)="")) AND
(((tblAllRuns.ASSIGNEE)=[Forms]![frmReports]![cboAssignee]) OR
((tblAllRuns.ASSIGNEE)="")) AND
(((tblAllRuns.VALUE)=[Forms]![frmReports]![cboValue]) OR
((tblAllRuns.VALUE)="")));

Thanks!
 
K

KC_Cheer_Coach

I figured it out. This is what I did. Sorry if I wasted anyone's time.

SELECT tblAllRuns.[RUN NBR], tblAllRuns.SYSTEM, tblAllRuns.CYCLE,
tblAllRuns.TASK, tblAllRuns.ASSIGNEE, tblAllRuns.VALUE, tblAllRuns.HOURS,
tblAllRuns.MIN, tblAllRuns.TOTAL
FROM tblAllRuns
WHERE ((((tblAllRuns.[RUN NBR])=[Forms]![frmReports]![cboRun]) OR
(([Forms]![frmReports]![cboRun]) IS NULL)) AND
(((tblAllRuns.SYSTEM)=[Forms]![frmReports]![cboSystem]) OR
(([Forms]![frmReports]![cboSystem]) IS NULL)) AND
(((tblAllRuns.CYCLE)=[Forms]![frmReports]![cboCycle]) OR
(([Forms]![frmReports]![cboCycle]) IS NULL))
AND (((tblAllRuns.TASK)=[Forms]![frmReports]![cboTask]) OR
(([Forms]![frmReports]![cboTask]) IS NULL)) AND
(((tblAllRuns.ASSIGNEE)=[Forms]![frmReports]![cboAssignee]) OR
(([Forms]![frmReports]![cboAssignee]) IS NULL)) AND
(((tblAllRuns.VALUE)=[Forms]![frmReports]![cboValue]) OR
(([Forms]![frmReports]![cboValue]) IS NULL)));

Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top