Combo Box, Query and Report

G

Guest

I have a switchboard that has a button for Reports, the Reports switchboard
has a selection of reports. One of the reports is called "Detail by Specific
Employee." When this button is clicked, I'd like the report (in print
preview) to show for that specific employee.

Names:
Combo box: cboEmployeeName
Query: qry Specific Employee
Form: frmEmployeeLocator
Report: rpt By Specific Employee

On the Form, the "OK" command button has the following code:

Private Sub cmdOK_Click()
DoCmd.OpenQuery "qry Specific Employee"
DoCmd.Close acForm, "frmEmployeeLocator"
End Sub

The query has the following criteria under Employee Name:
[Forms]![FrmEmployeeLocator]![cboEmployeeName]

I get the correct data, but it is in database/query format and not the
report. I can't figure out the rest. I am using 2007. Please help.

Thank you!
 
G

Guest

Hi,

It isn't working because you closed the "frmEmployeeLocator".

When you close the form, there's no "employee id" for the query to pull
from, that's why you don't get the data result as limited by your selection.

If you remove the line

DoCmd.Close acForm, "frmEmployeeLocator"

you'll be fine.

You can use the option of making the frm hidden, or close it after the query
has ran...just not before.
 
G

Guest

Thank you for the quick reply. The result I still get is in query format,
not the report.
--
MB


DCPan said:
Hi,

It isn't working because you closed the "frmEmployeeLocator".

When you close the form, there's no "employee id" for the query to pull
from, that's why you don't get the data result as limited by your selection.

If you remove the line

DoCmd.Close acForm, "frmEmployeeLocator"

you'll be fine.

You can use the option of making the frm hidden, or close it after the query
has ran...just not before.

MB said:
I have a switchboard that has a button for Reports, the Reports switchboard
has a selection of reports. One of the reports is called "Detail by Specific
Employee." When this button is clicked, I'd like the report (in print
preview) to show for that specific employee.

Names:
Combo box: cboEmployeeName
Query: qry Specific Employee
Form: frmEmployeeLocator
Report: rpt By Specific Employee

On the Form, the "OK" command button has the following code:

Private Sub cmdOK_Click()
DoCmd.OpenQuery "qry Specific Employee"
DoCmd.Close acForm, "frmEmployeeLocator"
End Sub

The query has the following criteria under Employee Name:
[Forms]![FrmEmployeeLocator]![cboEmployeeName]

I get the correct data, but it is in database/query format and not the
report. I can't figure out the rest. I am using 2007. Please help.

Thank you!
 
G

Guest

I just made the following change:

DoCmd.OpenQuery "qry Specific Employee"
DoCmd.OpenReport "rpt By Specific Employee"

It will automatically print out the report for the specific employee, but I
would like to to show the report in print preview instead. I can't find
where to make that change. Please help.
--
MB


MB said:
Thank you for the quick reply. The result I still get is in query format,
not the report.
--
MB


DCPan said:
Hi,

It isn't working because you closed the "frmEmployeeLocator".

When you close the form, there's no "employee id" for the query to pull
from, that's why you don't get the data result as limited by your selection.

If you remove the line

DoCmd.Close acForm, "frmEmployeeLocator"

you'll be fine.

You can use the option of making the frm hidden, or close it after the query
has ran...just not before.

MB said:
I have a switchboard that has a button for Reports, the Reports switchboard
has a selection of reports. One of the reports is called "Detail by Specific
Employee." When this button is clicked, I'd like the report (in print
preview) to show for that specific employee.

Names:
Combo box: cboEmployeeName
Query: qry Specific Employee
Form: frmEmployeeLocator
Report: rpt By Specific Employee

On the Form, the "OK" command button has the following code:

Private Sub cmdOK_Click()
DoCmd.OpenQuery "qry Specific Employee"
DoCmd.Close acForm, "frmEmployeeLocator"
End Sub

The query has the following criteria under Employee Name:
[Forms]![FrmEmployeeLocator]![cboEmployeeName]

I get the correct data, but it is in database/query format and not the
report. I can't figure out the rest. I am using 2007. Please help.

Thank you!
 
G

Guest

Try

DoCmd.OpenReport "rpt By Specific Employee", acPreview


MB said:
I just made the following change:

DoCmd.OpenQuery "qry Specific Employee"
DoCmd.OpenReport "rpt By Specific Employee"

It will automatically print out the report for the specific employee, but I
would like to to show the report in print preview instead. I can't find
where to make that change. Please help.
--
MB


MB said:
Thank you for the quick reply. The result I still get is in query format,
not the report.
--
MB


DCPan said:
Hi,

It isn't working because you closed the "frmEmployeeLocator".

When you close the form, there's no "employee id" for the query to pull
from, that's why you don't get the data result as limited by your selection.

If you remove the line

DoCmd.Close acForm, "frmEmployeeLocator"

you'll be fine.

You can use the option of making the frm hidden, or close it after the query
has ran...just not before.

:

I have a switchboard that has a button for Reports, the Reports switchboard
has a selection of reports. One of the reports is called "Detail by Specific
Employee." When this button is clicked, I'd like the report (in print
preview) to show for that specific employee.

Names:
Combo box: cboEmployeeName
Query: qry Specific Employee
Form: frmEmployeeLocator
Report: rpt By Specific Employee

On the Form, the "OK" command button has the following code:

Private Sub cmdOK_Click()
DoCmd.OpenQuery "qry Specific Employee"
DoCmd.Close acForm, "frmEmployeeLocator"
End Sub

The query has the following criteria under Employee Name:
[Forms]![FrmEmployeeLocator]![cboEmployeeName]

I get the correct data, but it is in database/query format and not the
report. I can't figure out the rest. I am using 2007. Please help.

Thank you!
 
J

John Spencer

By the way, if the query is the record source for the report then there is
no reason to open the query separately. The Report automatically runs the
query when the report opens.

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

DCPan said:
Try

DoCmd.OpenReport "rpt By Specific Employee", acPreview


MB said:
I just made the following change:

DoCmd.OpenQuery "qry Specific Employee"
DoCmd.OpenReport "rpt By Specific Employee"

It will automatically print out the report for the specific employee, but
I
would like to to show the report in print preview instead. I can't find
where to make that change. Please help.
--
MB


MB said:
Thank you for the quick reply. The result I still get is in query
format,
not the report.
--
MB


:

Hi,

It isn't working because you closed the "frmEmployeeLocator".

When you close the form, there's no "employee id" for the query to
pull
from, that's why you don't get the data result as limited by your
selection.

If you remove the line

DoCmd.Close acForm, "frmEmployeeLocator"

you'll be fine.

You can use the option of making the frm hidden, or close it after
the query
has ran...just not before.

:

I have a switchboard that has a button for Reports, the Reports
switchboard
has a selection of reports. One of the reports is called "Detail
by Specific
Employee." When this button is clicked, I'd like the report (in
print
preview) to show for that specific employee.

Names:
Combo box: cboEmployeeName
Query: qry Specific Employee
Form: frmEmployeeLocator
Report: rpt By Specific Employee

On the Form, the "OK" command button has the following code:

Private Sub cmdOK_Click()
DoCmd.OpenQuery "qry Specific Employee"
DoCmd.Close acForm, "frmEmployeeLocator"
End Sub

The query has the following criteria under Employee Name:
[Forms]![FrmEmployeeLocator]![cboEmployeeName]

I get the correct data, but it is in database/query format and not
the
report. I can't figure out the rest. I am using 2007. Please
help.

Thank you!
 

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