How to program a pop up box to select specific records in a report

J

Joni

I am having problems programming a pop up box to be able to select a "month" for a report. I would like the report to only select the records that pertain to a specific month to print.

I know I can do this by typing in the month that I want to see in the criteria box in the query. I just hate to change that every month so I can only see those records.

Please help!!!! I have been struggling with this for many long hours and days!!

Thanks,
Joni
 
G

Gary Miller

Joni,

I am not clear if your Month is in a date or text format,
but if you say you can do it by typing it in the Criteria
line of a query, I will assume that it is a text field. Two
common approaches to this are...

In the criteria box of the query type in the following, but
substitute your form and field names...

[Forms]![YourFormName]![YourMonthFieldName]

This will cause the query to examine the form to figure out
what month. Form needs to remain open when you open the
report. The command button wizard can set up a button to do
this or you could code the DoCmd.OpenReport into the button
yourself.

Second method is actually more flexible as it doesn't limit
the query to looking at that form so you can use it other
places. This is to just use the above OpenReport method and
use it's WHERE clause to tell it which record(s). This would
usually go behind the AfterUpdate event of your Month
selector or behind the OnClick event of a command button.

DoCmd.OpenReport "YourReport", acViewPreview, , "[Month] =
'" & Me!Month & "'"

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
Joni said:
I am having problems programming a pop up box to be able
to select a "month" for a report. I would like the report
to only select the records that pertain to a specific month
to print.
I know I can do this by typing in the month that I want to
see in the criteria box in the query. I just hate to change
that every month so I can only see those records.
 
J

Jeff Boyce

Joni

As Gary points out, an answer will depend on your data. From your
description, it sounds like you are storing month names. If you describe
your data and data structure a bit more, the 'group readers may be able to
help a bit more.

More info, please...

Jeff Boyce
<Access MVP>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top