Getting report based on criteria matching in combo...

kate10123

Registered User.
Local time
Today, 00:51
Joined
Jul 31, 2008
Messages
185
Hi there,

I have four combo boxes called:

categories
student
period
year

Each have a series of items in them.

categories
By Gender
By Nationality

student
All
New

period
Monthly
Yearly

year
2007
2008
2009

What I want to do is write some vb which takes the users selections from these combo boxes and opens the relevant report on clicking a button.
All the reports are created so it's just a case of putting the right report against the user's selections.

I have a button called preview so I know that the code has to go in the 'on_click' event.

So using the above as an example, how would I write the following kind of code but referencing the combo box selections.

if categories = 'By Gender' and student = 'New' then
DoCmd.OpenReport (Gender - new)
else if...
Any support appreciated!
 
you would do
Code:
if me.yourcomboname = "by gender" then

if me.yourstudentcomboname= "new" then
                   if me.youryearcombo="2007"
                   open 2007 report
                   else if me.youryearcombo="2008"
                   open 2008 report
                   else
                   open 2009 report
                   end if
else
if me.youryearcombo="2007"
                   open 2007 All report
                   else if me.youryearcombo="2008"
                   open 2008 All report 
                   else
                   open 2009 All report
                   end if
end if
else
if me.yourstudentcomboname= "new" then
                   if me.youryearcombo="2007"
                   open 2007 report by nationality
etc....
 
Thanks for that.

I wonder if there a better solution for the future in that by using vba to look for specific report names will constantly need to be updated as and when new criteria is decided and new reports created.

Do you think listboxes might overcome this?
 
yeah you could open them based on link criteria also, but it sounds like you have already created all the reports, what you could do is create 1 report, and filter based on that.

OR maybe i just assumed that and i am totally wrong??

either way, you could do with the strlinkcriteria.

one question, are by gender and by nationality sort options?
 

Users who are viewing this thread

Back
Top Bottom