Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2003, 12:07 PM
Authorized User
 
Join Date: Nov 2003
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Generate reports from Listbox Or WhereClause help

I have a list box that lists the three types of proposals I work on. When a type is selected, you can generate a report of only those types of proposals. The listbox is filled with a query of all proposal types.

I would like to generate a report based on two types of proposals. i.e A report of all Proposal type 1 and type 2 but excluding type 3.

Is there a way to add another report option (type 4 = type 1 + type 2) to the listbox?

Is there also a way to add another option (say a type 5) that would include all the other types (types 1, 2 and 3)?

The above would be ideal, but I could not figure it out. I also tried making separate command buttons for these 'special' reports, but was unable to get the 'where' syntax correct. So I kept getting the wrong report. If my first two questions (adding these special report types to the listbox with the other options) are not possible, can someone offer another solution and/or possibly help with the WHERE syntax so I get the correct results?

Here is my non-working code for one of the command buttons, if anyone can tell me what is wrong...

Private Sub cmdPrevFULLandRET_Click()

DoCmd.OpenReport "repProposalActivity", acViewPreview, , "[project_type]= 'Full Proposal' Or 'Retention Exercise'"

End Sub

I hope I explained myself properly, I am still quite new to VBA. If anyone can help, I would be very thankful.

Thanks,
Nick
 
Old November 6th, 2003, 06:36 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I might take a different approach to solving this. It's not all the different, but what I would do is build an SQL statement based on what is selected (either use a multi-select option in your list box, or option group, or etc.) then have the SQL string populate a Recordset variable, and then one last thing is to set that to the report's recordset in the "On Open" event of the report.

I use this all the time and it works very well.

John





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to generate reports from access using queries nebujacob2000 Access VBA 3 November 18th, 2005 05:11 AM
Problems with whereclause blaabil Classic ASP Databases 7 July 14th, 2005 11:20 AM
How to generate sequence reports VBA Baby Access VBA 1 May 12th, 2005 06:55 AM
whereclause use in a Data Grid acorbo ASP.NET 1.0 and 1.1 Professional 4 August 11th, 2004 07:37 AM
How to generate data reports gandhichirag Pro VB 6 0 July 5th, 2004 08:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.