A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Defining recordsource for report including "all"



 
 
Thread Tools Display Modes
  #1  
Old July 9th, 2004, 02:21 PM
Melanie O
external usenet poster
 
Posts: n/a
Default Defining recordsource for report including "all"

I have a simple form with a combox box and a command button for opening a report. Currently, the recordsource for the report is based on a query that filters the data from the combo box selection and only shows those records belonging to the selected group on the report. I added code behind the combo box to include all groups as well:

Combo0.RowSource = "SELECT [BU_ID], [BU_NAME] FROM tbl_BUSINESS_UNIT ORDER BY BU_NAME " & _
"UNION SELECT 0 AS [BU_ID], 'All Groups' AS [BU_NAME] FROM tbl_BUSINESS_UNIT;"
Combo0 = ""

How do I write the code to set the recordsource for the report that can be either one of the groups from the combo box or all groups? Thanks.

  #2  
Old July 10th, 2004, 05:45 AM
Steve Schapel
external usenet poster
 
Posts: n/a
Default Defining recordsource for report including "all"

Melanie,

There is no need for any code to do this. Just put the criteria in the
BU_ID field in your query like this...
[Forms]![YourFormName]![Combo0] Or [Forms]![YourFormName]![Combo0]=0

By the way, speaking of code, what is the purpose of the line Combo0 =
"" in the code you showed us? On the face of it, it would seem to be
incorrect.

--
Steve Schapel, Microsoft Access MVP


Melanie O wrote:
I have a simple form with a combox box and a command button for
opening a report. Currently, the recordsource for the report is
based on a query that filters the data from the combo box selection
and only shows those records belonging to the selected group on the
report. I added code behind the combo box to include all groups as
well:

Combo0.RowSource = "SELECT [BU_ID], [BU_NAME] FROM tbl_BUSINESS_UNIT
ORDER BY BU_NAME " & _ "UNION SELECT 0 AS [BU_ID], 'All Groups' AS
[BU_NAME] FROM tbl_BUSINESS_UNIT;" Combo0 = ""

How do I write the code to set the recordsource for the report that
can be either one of the groups from the combo box or all groups?
Thanks.

  #3  
Old July 12th, 2004, 05:15 PM
Melanie O
external usenet poster
 
Posts: n/a
Default Defining recordsource for report including "all"

Never mind. I figured it out. Sorry for the extra post(s).

"Melanie O" wrote:

I have a simple form with a combox box and a command button for opening a report. Currently, the recordsource for the report is based on a query that filters the data from the combo box selection and only shows those records belonging to the selected group on the report. I added code behind the combo box to include all groups as well:

Combo0.RowSource = "SELECT [BU_ID], [BU_NAME] FROM tbl_BUSINESS_UNIT ORDER BY BU_NAME " & _
"UNION SELECT 0 AS [BU_ID], 'All Groups' AS [BU_NAME] FROM tbl_BUSINESS_UNIT;"
Combo0 = ""

How do I write the code to set the recordsource for the report that can be either one of the groups from the combo box or all groups? Thanks.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can recordsource parameters be set in code? Using Forms 1 June 15th, 2004 04:56 AM
Changed recordsource = nodata Atlas Setting Up & Running Reports 1 June 1st, 2004 10:41 PM
Problem with defining my own table style! mca Tables 0 June 1st, 2004 09:23 AM
Records "lost" when OLE added to RecordSource JohnLute Using Forms 1 May 30th, 2004 06:42 PM


All times are GMT +1. The time now is 06:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.