473,419 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 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 12446


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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.