Two combo box for a report

W

Wonderer

Hello,

A blessed day to you all! I have another question regarding reports.
Let me try to explain this as far as i can..Please bear with me..

What i have done so far..

I have a simple report to display Issue Vouchers for a Certain Site.

I have created an unbound form with a Combo Box (List of Site i have
created base on the Site table) which will ask the user what Site only
to be displayed in the report, so basically the user is trying to
filter.

So when the user choose a site example, Head Office and press the
Preview button then the report will filter and display the report with
only the voucher numbers under Head Office.

The first part is done actually i just wanted to explain all what's
happening, and i just wanted to add something..please see below...

Now i wanted to add another Combo box for the Department inside that
unbound form where the combo box for site is. And when the user choose
the Head Office then the Department from the combo box let say, ITD
and press the Preview button then the report will filter and display
the report with only the voucher numbers under Site: Head Office and
Department: ITD.

And if the user what to display the entire vouchers for Head Office he
will just leave the Combo Box for the Department blank or empty then
click the preview button then the issue vouchers for the entire head
office will be displayed.

Hope you can help with this one...Thanks in advance!
 
D

Duane Hookom

I generally filter reports using the Where Condition of the DoCmd.OpenReport
method. The code to open a report looks something like:

Dim strWhere as String
Dim strReport as String
strReport = "rptMyReport"
strWhere = "1=1 "
If not IsNull(Me.cboSite) Then
'assuming Site is numeric
strWhere = strWhere & " AND [Site] = " & Me.cboSite
End If
If not IsNull(Me.cboDept) Then
'assuming Dept is text
strWhere = strWhere & " AND [Dept] = """ & Me.cboDept & """"
End If
DoCmd.OpenReport strReport, acPreview, , strWhere
 
W

Wonderer

Wow! This is perfect! It works in a blink of an eye! Thank you Duane for a
wonderful instruction...More power!

Wish soon i can be like you people! Thanks for this thread! Really help us
newbie....

Duane Hookom said:
I generally filter reports using the Where Condition of the DoCmd.OpenReport
method. The code to open a report looks something like:

Dim strWhere as String
Dim strReport as String
strReport = "rptMyReport"
strWhere = "1=1 "
If not IsNull(Me.cboSite) Then
'assuming Site is numeric
strWhere = strWhere & " AND [Site] = " & Me.cboSite
End If
If not IsNull(Me.cboDept) Then
'assuming Dept is text
strWhere = strWhere & " AND [Dept] = """ & Me.cboDept & """"
End If
DoCmd.OpenReport strReport, acPreview, , strWhere

--
Duane Hookom
Microsoft Access MVP


Wonderer said:
Hello,

A blessed day to you all! I have another question regarding reports.
Let me try to explain this as far as i can..Please bear with me..

What i have done so far..

I have a simple report to display Issue Vouchers for a Certain Site.

I have created an unbound form with a Combo Box (List of Site i have
created base on the Site table) which will ask the user what Site only
to be displayed in the report, so basically the user is trying to
filter.

So when the user choose a site example, Head Office and press the
Preview button then the report will filter and display the report with
only the voucher numbers under Head Office.

The first part is done actually i just wanted to explain all what's
happening, and i just wanted to add something..please see below...

Now i wanted to add another Combo box for the Department inside that
unbound form where the combo box for site is. And when the user choose
the Head Office then the Department from the combo box let say, ITD
and press the Preview button then the report will filter and display
the report with only the voucher numbers under Site: Head Office and
Department: ITD.

And if the user what to display the entire vouchers for Head Office he
will just leave the Combo Box for the Department blank or empty then
click the preview button then the issue vouchers for the entire head
office will be displayed.

Hope you can help with this one...Thanks in advance!
 

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