Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

report help

Status
Not open for further replies.

ka1924

Programmer
Jun 20, 2006
6
US
I generated a report. So I created 2 combo boxes and one list box on the form.
In Combo boxes select crieteria 1. Branch 2. Department. Report names were listed on the list box.
I created in query crieteria [forms]![forsname]![comboname] for branch and Department.
When the user selects the data from the two combo boxes and then double click on the report name in the list box,It is printing the report based on the combo selection.

If the user selects the branch name from the combo box and has not selected anything else from the department combo box and when the user clicked on the report name in the list box it has to print the report from all the departments information under that branch name. How can i change the cireteria in the query or is there any way to create a code on the list box event procedure?

I appreciate your help.
 
I almost always remove the criteria from the record source query and use the Where clause in the DoCmd.OpenReport method.
Code:
Dim strWhere as String
Dim strRpt as String
strRpt = Me.lboReport
strWhere = "1=1 "
If Not IsNull(Me.cboBranch) Then
  strWhere = strWhere & " And [Branch]=""" & Me.cboBranch & """"
End If
If Not IsNull(Me.cboDept) Then
  strWhere = strWhere & " And [Dept]=""" & Me.cboDept & """"
End If
DoCmd.OpenReport strRpt, acPreview, , strWhere

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top