Actually, maybe I express my-self wrong, I am sorry. I don't want to count unique P/N but how many different P/N we received, which sound very similar to me. In the last example, the sort is done by date (I forgot to mention it). Here is what the result is suppose to look like:
P/N Date Quantity Selling Price ...
C6WM4567-1 2004-05-05 5 100$
C6FM7694-12 2004-05-06 2 50$
C6WM4567-1 2004-05-17 3 100$
Now, here is a sample of code I use to apply filter
Private Sub SetFilter_Click()
Dim strSQL As String
Dim intCounter As Integer
For intCounter = 1 To 12
If Me("Filter" & intCounter) <> "" Then
strSQL = strSQL & "[" & Me("Filter" & intCounter).Tag & "] " & " = " & Chr(34) & Me("Filter" & intCounter) & _
Chr(34) & " And "
End If
Next
If strSQL <> "" Then
strSQL = Left(strSQL, (Len(strSQL) - 5))
Reports![RPT-PNDynamic].Filter = strSQL
Reports![RPT-PNDynamic].FilterOn = True
End If
End Sub
The running sum and calculated fields cannot be done with a query because the report's contain change dynamically without reload it. Besides, the report is loaded by the pop-up form so if I base the report on a query the query criteria will be valid only when the report is loaded. Then, by filter dynamically, the criteria change but the query remains the same. Unfortunately, if I want to place reference to the pop-up form's controls in the query it is not working because the query is loaded before the pop-up form is appeared. Then, I am prompting to enter manually what the query is supposed to get from the pop-up form.
Hopping again those details will help you figured out what I am trying to do.
Thank you.
----- Duane Hookom wrote: -----
I don't see in your example where the count of unique P/Ns is located. Also,
the sort looks much the same in both example lists. I have never relied on
setting the OrderBy property. You could filter a group by query so that you
could count unique P/Ns. I don't know how you are building your filter on
your main report.
--
Duane Hookom
MS Access MVP
Yanick said:
I, in fact, don't want separate groups because it causes my sorting to go
wrong. My report's record source is the Table it self because I wanted to
create a report that open with all the records on it and than give you the
choice to filter and sort dynamically what you want on it by the pop-up form
(to give extreme flexibility). The filter/sort are done by building SQL
expression (in VB) and affect them to the report's filter/orderby
properties. Once it is filter/sort the way I want, I need to put the number
of unique record in a summery located in the report footer section.
Selling Price ...
C6WM4567-1 2004-05-17 3 100$
C6WM4567-1 2004-05-05 5 100$
C6FM7694-12 2004-05-06 2 50$
will be easily able to know how many unique P/N there are (by counting the
number of group) but than if I sort the report (dynamically) here is the
result:
Selling Price ...
C6WM4567-1 2004-05-05 5 100$
C6WM4567-1 2004-05-17 3 100$
C6FM7694-12 2004-05-06 2 50$
strong in VB but don't know the Access/SQL mechanic very well. I am sure
there is an easy way to do what I want but unfortunately we cannot put SQL
expression in a textbox's record source properties.