472,796 Members | 1,460 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,796 software developers and data experts.

Create a report using a parameter from a combo box

I have a form called OwnerForm. It contains a combo box called
Owner. The combo box looks up names from a table called OwnerName.
It contains fields called OwnerID and Owner. I also have a main form
called ProjectsForm. This form has several fields to enter data. I
have a query that is called Owner Query. This query contains the
fields IDNumber.Projects2 Team.Projects2 and Owner.OwnerName getting
information from tables.

On the criteria of Owner I have:

forms!OwnerForm!Owner.

I want the query to only show the data from the Projects2 table that
matches the name on the combo box. I made a report called Owner
Report. I have a command button on the OwnerForm form which opens the
report in Preview. I can't seem to get the report to show any data.
It is a blank report. When I open the report from the form it is
blank. When I open the report from the report list it sends me to the
form I choose the name from the combo box then click on the command
button, it prompts me to a Enter Parameter Value. When I type in a
name it will generate the report with the proper information, but I
want the combo box to send it to the report and not have to type it
in. The record source for the report is

SELECT [OwnerName].[Owner], [Projects2].[ID Number], [Projects2].
[Team] FROM OwnerName INNER JOIN Projects2 ON [OwnerName].
[Owner]=[Projects2].[Owner] WHERE ((([OwnerName].[Owner])=[forms]!
[OwnerForm]![Owner]));

I also have the report open and close events as follows: It seems to
work ok.

Private Sub Report_Close()
DoCmd.Close acForm, "Owner Report"

End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "OwnerForm", , , , , acDialog

Any ideas would be appreciated.
End Sub

Jan 30 '07 #1
6 12382


On Jan 30, 11:22 am, "fieldja" <jfie...@socket.netwrote:
I have a form called OwnerForm. It contains a combo box called
Owner. The combo box looks up names from a table called OwnerName.
It contains fields called OwnerID and Owner. I also have a main form
called ProjectsForm. This form has several fields to enter data. I
have a query that is called Owner Query. This query contains the
fields IDNumber.Projects2 Team.Projects2 and Owner.OwnerName getting
information from tables.

On the criteria of Owner I have:

forms!OwnerForm!Owner.

I want the query to only show the data from the Projects2 table that
matches the name on the combo box. I made a report called Owner
Report. I have a command button on the OwnerForm form which opens the
report in Preview. I can't seem to get the report to show any data.
It is a blank report. When I open the report from the form it is
blank. When I open the report from the report list it sends me to the
form I choose the name from the combo box then click on the command
button, it prompts me to a Enter Parameter Value. When I type in a
name it will generate the report with the proper information, but I
want the combo box to send it to the report and not have to type it
in. The record source for the report is

SELECT [OwnerName].[Owner], [Projects2].[ID Number], [Projects2].
[Team] FROM OwnerName INNER JOIN Projects2 ON [OwnerName].
[Owner]=[Projects2].[Owner] WHERE ((([OwnerName].[Owner])=[forms]!
[OwnerForm]![Owner]));

I also have the report open and close events as follows: It seems to
work ok.

Private Sub Report_Close()
DoCmd.Close acForm, "Owner Report"

End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.OpenForm "OwnerForm", , , , , acDialog

Any ideas would be appreciated.
End Sub
My guess is you have the BoundColumn incorrectly set on the "Owner"
combo box to the default of 1, which looks to be the field
IDNumber.Projects2 in your query. Set the Bound Column property to
3, which is the Owner.OwnerName in your query. You want to make sure
the value of the combo box is the name of the owner of the project
because that is the criteria you are basing the report on. The Bound
Column property determines the field from the query you have specified
in the Row Source that should be used as the value of the combo box.

Regards,

n00b

Jan 30 '07 #2
Why don't you use the filter criteria when opening the report.

See the following kb-article for an example:
http://support.microsoft.com/kb/q147143/

Jan 30 '07 #3
On Jan 30, 11:38 am, "Mike" <michael.matt...@hotmail.comwrote:
Why don't you use the filter criteria when opening the report.

See the following kb-article for an example:http://support.microsoft.com/kb/q147143/
Thanks for the information.

I think I am getting close to making it work, but I am still having
problems.

When I run the filter I get an error message:
Syntax error (missing operator) in query expression '[Team] = "Clutch
Plate" An)'.
The An should be And.
I don't know why it is cutting that word off?
I also, don't know why it won't work for me? I applied the example to
my application and changed the table names and fields to my own
names. Also, I only wanted 3 combo boxes instead of 5, like in the
example. So I changed those values to 3.

Here is my Filter:

Private Sub Set_Filter_Click()

Dim strSQL As String, intCounter As Integer 'Build SQL string.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <" " Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]
" & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next

If strSQL <"" Then ' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 3)) ' Set the Filter
Property.
Reports![rptOwner].Filter = strSQL
Reports![rptOwner].FilterOn = True
End If

End Sub
I have a table called Projects2 that I am using to get information
from. I have 3 combo boxes. Owner, Team, Status.

Here are the Row Sources:
SELECT DISTINCT [Owner] FROM Projects2 ORDER BY [Owner];

SELECT DISTINCT [Team] FROM Projects2 ORDER BY [Team];

SELECT DISTINCT [Status] FROM Projects2 ORDER BY [Status];

Is the "Filter" in the Set_Filter code correct? Or does it need to
read "Set Filter"?

I am at a loss as what to do, any help would be appreciative.
Feb 6 '07 #4
On Feb 6, 10:39 am, "fieldja" <jfie...@socket.netwrote:
On Jan 30, 11:38 am, "Mike" <michael.matt...@hotmail.comwrote:
Why don't you use the filter criteria when opening the report.
See the following kb-article for an example:http://support.microsoft.com/kb/q147143/

Thanks for the information.

I think I am getting close to making it work, but I am still having
problems.

When I run the filter I get an error message:
Syntax error (missing operator) in query expression '[Team] = "Clutch
Plate" An)'.
The An should be And.
I don't know why it is cutting that word off?
I also, don't know why it won't work for me? I applied the example to
my application and changed the table names and fields to my own
names. Also, I only wanted 3 combo boxes instead of 5, like in the
example. So I changed those values to 3.

Here is my Filter:

Private Sub Set_Filter_Click()

Dim strSQL As String, intCounter As Integer 'Build SQL string.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <" " Then

strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]
" & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next

If strSQL <"" Then ' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 3)) ' Set the Filter
Property.
Reports![rptOwner].Filter = strSQL
Reports![rptOwner].FilterOn = True
End If

End Sub

I have a table called Projects2 that I am using to get information
from. I have 3 combo boxes. Owner, Team, Status.

Here are the Row Sources:
SELECT DISTINCT [Owner] FROM Projects2 ORDER BY [Owner];

SELECT DISTINCT [Team] FROM Projects2 ORDER BY [Team];

SELECT DISTINCT [Status] FROM Projects2 ORDER BY [Status];

Is the "Filter" in the Set_Filter code correct? Or does it need to
read "Set Filter"?

I am at a loss as what to do, any help would be appreciative.
I think I got it!

I had spaces in between some the "" and also in the "and" section of
the code. Once I deleted those spaces the filter worked.

Thanks again.

Feb 6 '07 #5
On Feb 6, 10:59 am, "fieldja" <jfie...@socket.netwrote:
On Feb 6, 10:39 am, "fieldja" <jfie...@socket.netwrote:


On Jan 30, 11:38 am, "Mike" <michael.matt...@hotmail.comwrote:
Why don't you use the filter criteria when opening the report.
See the following kb-article for an example:http://support.microsoft.com/kb/q147143/
Thanks for the information.
I think I am getting close to making it work, but I am still having
problems.
When I run the filter I get an error message:
Syntax error (missing operator) in query expression '[Team] = "Clutch
Plate" An)'.
The An should be And.
I don't know why it is cutting that word off?
I also, don't know why it won't work for me? I applied the example to
my application and changed the table names and fields to my own
names. Also, I only wanted 3 combo boxes instead of 5, like in the
example. So I changed those values to 3.
Here is my Filter:
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer 'Build SQL string.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <" " Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]
" & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <"" Then ' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 3)) ' Set the Filter
Property.
Reports![rptOwner].Filter = strSQL
Reports![rptOwner].FilterOn = True
End If
End Sub
I have a table called Projects2 that I am using to get information
from. I have 3 combo boxes. Owner, Team, Status.
Here are the Row Sources:
SELECT DISTINCT [Owner] FROM Projects2 ORDER BY [Owner];
SELECT DISTINCT [Team] FROM Projects2 ORDER BY [Team];
SELECT DISTINCT [Status] FROM Projects2 ORDER BY [Status];
Is the "Filter" in the Set_Filter code correct? Or does it need to
read "Set Filter"?
I am at a loss as what to do, any help would be appreciative.

I think I got it!

I had spaces in between some the "" and also in the "and" section of
the code. Once I deleted those spaces the filter worked.

Thanks again.- Hide quoted text -

- Show quoted text -
Sorry, I thought it worked but it did not.
Feb 6 '07 #6
On Feb 6, 3:14 pm, "fieldja" <jfie...@socket.netwrote:
On Feb 6, 10:59 am, "fieldja" <jfie...@socket.netwrote:


On Feb 6, 10:39 am, "fieldja" <jfie...@socket.netwrote:
On Jan 30, 11:38 am, "Mike" <michael.matt...@hotmail.comwrote:
Why don't you use the filter criteria when opening the report.
See the following kb-article for an example:http://support.microsoft.com/kb/q147143/
Thanks for the information.
I think I am getting close to making it work, but I am still having
problems.
When I run the filter I get an error message:
Syntax error (missing operator) in query expression '[Team] = "Clutch
Plate" An)'.
The An should be And.
I don't know why it is cutting that word off?
I also, don't know why it won't work for me? I applied the example to
my application and changed the table names and fields to my own
names. Also, I only wanted 3 combo boxes instead of 5, like in the
example. So I changed those values to 3.
Here is my Filter:
Private Sub Set_Filter_Click()
Dim strSQL As String, intCounter As Integer 'Build SQL string.
For intCounter = 1 To 3
If Me("Filter" & intCounter) <" " Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "]
" & " = " & Chr(34) & Me("Filter" & intCounter) & Chr(34) & " And "
End If
Next
If strSQL <"" Then ' Strip Last " And ".
strSQL = Left(strSQL, (Len(strSQL) - 3)) ' Set the Filter
Property.
Reports![rptOwner].Filter = strSQL
Reports![rptOwner].FilterOn = True
End If
End Sub
I have a table called Projects2 that I am using to get information
from. I have 3 combo boxes. Owner, Team, Status.
Here are the Row Sources:
SELECT DISTINCT [Owner] FROM Projects2 ORDER BY [Owner];
SELECT DISTINCT [Team] FROM Projects2 ORDER BY [Team];
SELECT DISTINCT [Status] FROM Projects2 ORDER BY [Status];
Is the "Filter" in the Set_Filter code correct? Or does it need to
read "Set Filter"?
I am at a loss as what to do, any help would be appreciative.
I think I got it!
I had spaces in between some the "" and also in the "and" section of
the code. Once I deleted those spaces the filter worked.
Thanks again.- Hide quoted text -
- Show quoted text -

Sorry, I thought it worked but it did not.- Hide quoted text -

- Show quoted text -
I was able to get the filter to work on all the combo boxes except for
the ID Number box. Is that because the data is an auto number instead
of text?

Any ideas?

Feb 9 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MJ | last post by:
Hi, I'm hoping this is relatively easy. I have a report based on a query - when you run the report, a form opens up and you are prompted for a date range. These are combo boxes (ie. January...
3
by: amywolfie | last post by:
Hi All: I would like to run a report based on criteria from 3 unbound combo boxes located on a parameter form (combo boxes are: cboCuisine, cboLocation, and cboRestaurant) The present code...
1
by: allie357 | last post by:
I am trying to add a form with a combo box to an existing parameter query report. I followed the directions from this link:http://office.microsoft.com/en-us/assistance/HA011170771033.aspx ...
1
by: Jack | last post by:
Hello All, Can anyone here suggest me a solution to solve my follwoing problem? 1) I got a .aspx page and on that page i got a combo box and a command button. Combo box displays records from the...
6
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate...
3
by: gmazza via AccessMonster.com | last post by:
Hi there, I am trying to run a report using a parameter for where the user chooses a month from a combo box. Then on the report, I want it to compare the month to a date field and choose only...
2
by: yogeshtiwarijbp | last post by:
Hi All, Iam new in asp.net 2003 and sql server. I have to create an application having following criteria. Proposed Steps 1. Create a table containing fields as Name of Report, View Name or...
10
by: vanlanjl | last post by:
I have created a form that contain two combo boxes and two cmd buttons. The idea of the form is that the user will select a search parameter from each combo box then will click the first cmd button...
8
by: danielb1952 | last post by:
I have created a form that uses the results of two queries: the first query is used to populate a combo box and then the selected value in the combo box is used as a parameter for the second query. ...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.