No reason you can't base the report on a table provided you use the
WhereCondition argument of the OpenReport method to open the report. as in
Duane's solution. Another similar approach would be to create an unbound
dialogue form and again add an unbound combo box to the form and a button to
open the report. The RowSource property for the combo box, cboBranchName
say, would be along these lines to list all braches alpahabetically:
SELECT BranchName FROM Branches ORDER BY BranchName;
And the code for the button's Click event procedure would be like this:
Dim strCriteria As String
strCriteria = "BranchName = """ & Me.cboBranchName & _
""" Or " & (Len(Me.cboBranchName & "") = 0)
DoCmd.OpenReport "YourReportNameGoesHere", _
View:=acViewPreview, _
WhereCondition:=strCriteria
This would open the report in print preview, filtering it to the selected
branch or returning all braches if the combo box is left blank. You might
want a second button to print the report, using exactly the same code but
with the omission of the line:
View:=acViewPreview, _
Ken Sheridan
Stafford, England
James said:
OK, I just realized something, I am basing the report on a table, not a
query...how to I even ask for criteria when the report is based on a table?
Or is this not possible?
I think you want your criteria looking like this;
Like Nz([Enter Branch Name], "*")
this way it will return * if left blank, resulting in all branches.
That NZ function simply means to use the 2nd option if the first is
null.