create a report with VBA

D

daMike

Hello,

I'm not really familiar with access and I should create a report.
What I have is a table with data and a form, where I select with
listboxes several filter criteria. What I need is a report based
on the source table where only the filtered datasets appear. The
report generation should be started by a button on the form, where
I select the filter criteria. Hope somebody have some example code
for me.

Thanks for any help!
daMike
 
S

SA

da:

You don't need to do this with VBA. 1.) Create your baseline report using
and unfiltered query for the data you need in the report (i.e. get all the
fields) and layout the report as you'd like it to look. 2.) Create your
form with text boxes or combo boxes to select the possible filters. Then
in the report's underlying query add in the conditions row a reference to
your form's controls for each appropriate field to use the data in the form
as the condition on the field, as in:

Like IIF(Not IsNull(Forms!MyForm!MyTextBox), Forms!MyForm!MyTextBox, "*")

This condition will test for whether a value has been put in the form's
field. If not, then it will use the Like "*" as the condition for that
field. "*" is the wild card character in Access and Like "*" means
effectively that there is no condition on that field.
 

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