Form Filter for Report

G

Guest

I have a form with a combo box listing employees (field = Employee) for the
user to select.

I have a report with a list of issues for each employee (field = AssignedTo)
that I want to filter according to what the user selected in the form.

Once the user selects the employee from the list, they click the OK button.
The code behind the Ok button assigns the variable strEmployee and then opens
the report.

This is where I fall apart. What code do I use (and where do I put it) to
get the report to filter by strEmployee?
 
D

Duane Hookom

It would help if you had included your code so that we could see your object
names. Generically....

Dim strWhere as String
strWhere = "[AssignedTo]=""" & Me.Employee & """"
DoCmd.OpenReport "rptGeneric", acPreview, , strWhere
 
G

Guest

Sorry for not putting in the code. I've listed it below with your
suggestions. However, I get a popup "paramaeter value" for Assigned To when
I do this.

Private Sub cmdOK_Click()

Dim strWhere As String

strWhere = "[AssignedTo]=""" & Me.Employee & """"

DoCmd.Close

DoCmd.OpenReport "rptIssues_ByAssignedTo", acPreview, , strWhere

End Sub

--
Debra Ann


Duane Hookom said:
It would help if you had included your code so that we could see your object
names. Generically....

Dim strWhere as String
strWhere = "[AssignedTo]=""" & Me.Employee & """"
DoCmd.OpenReport "rptGeneric", acPreview, , strWhere

--
Duane Hookom
MS Access MVP
--

Debra Ann said:
I have a form with a combo box listing employees (field = Employee) for the
user to select.

I have a report with a list of issues for each employee (field =
AssignedTo)
that I want to filter according to what the user selected in the form.

Once the user selects the employee from the list, they click the OK
button.
The code behind the Ok button assigns the variable strEmployee and then
opens
the report.

This is where I fall apart. What code do I use (and where do I put it) to
get the report to filter by strEmployee?
 
D

Duane Hookom

You had stated you had a field named AssignedTo in your report. Please
confirm this.

--
Duane Hookom
MS Access MVP
--

Debra Ann said:
Sorry for not putting in the code. I've listed it below with your
suggestions. However, I get a popup "paramaeter value" for Assigned To
when
I do this.

Private Sub cmdOK_Click()

Dim strWhere As String

strWhere = "[AssignedTo]=""" & Me.Employee & """"

DoCmd.Close

DoCmd.OpenReport "rptIssues_ByAssignedTo", acPreview, , strWhere

End Sub

--
Debra Ann


Duane Hookom said:
It would help if you had included your code so that we could see your
object
names. Generically....

Dim strWhere as String
strWhere = "[AssignedTo]=""" & Me.Employee & """"
DoCmd.OpenReport "rptGeneric", acPreview, , strWhere

--
Duane Hookom
MS Access MVP
--

Debra Ann said:
I have a form with a combo box listing employees (field = Employee) for
the
user to select.

I have a report with a list of issues for each employee (field =
AssignedTo)
that I want to filter according to what the user selected in the form.

Once the user selects the employee from the list, they click the OK
button.
The code behind the Ok button assigns the variable strEmployee and then
opens
the report.

This is where I fall apart. What code do I use (and where do I put it)
to
get the report to filter by strEmployee?
 
G

Guest

Thanks for making me check the report. I kept trying to find something wrong
in the form/code. Someone else working on the database changed the
"AssignedTo" field to "AssignedName". Once I fixed the code, it worked.

Thank you so much for your help. It is greatly appreciated.

--
Debra Ann


Duane Hookom said:
You had stated you had a field named AssignedTo in your report. Please
confirm this.

--
Duane Hookom
MS Access MVP
--

Debra Ann said:
Sorry for not putting in the code. I've listed it below with your
suggestions. However, I get a popup "paramaeter value" for Assigned To
when
I do this.

Private Sub cmdOK_Click()

Dim strWhere As String

strWhere = "[AssignedTo]=""" & Me.Employee & """"

DoCmd.Close

DoCmd.OpenReport "rptIssues_ByAssignedTo", acPreview, , strWhere

End Sub

--
Debra Ann


Duane Hookom said:
It would help if you had included your code so that we could see your
object
names. Generically....

Dim strWhere as String
strWhere = "[AssignedTo]=""" & Me.Employee & """"
DoCmd.OpenReport "rptGeneric", acPreview, , strWhere

--
Duane Hookom
MS Access MVP
--

I have a form with a combo box listing employees (field = Employee) for
the
user to select.

I have a report with a list of issues for each employee (field =
AssignedTo)
that I want to filter according to what the user selected in the form.

Once the user selects the employee from the list, they click the OK
button.
The code behind the Ok button assigns the variable strEmployee and then
opens
the report.

This is where I fall apart. What code do I use (and where do I put it)
to
get the report to filter by strEmployee?
 

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