M
mc
I have a subform that is using a select statement as its source. The select
statement is is using a group by, here is the coding:
SELECT tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number
FROM tblVendor_Acct INNER JOIN (tblVendor INNER JOIN tblAllocation_Hist ON
tblVendor.Vendor_ID = tblAllocation_Hist.Vendor_ID) ON
(tblVendor_Acct.Vendor_ID = tblVendor.Vendor_ID) AND
(tblVendor_Acct.Vendor_Acct_ID = tblAllocation_Hist.Vendor_Acct_ID)
GROUP BY tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number
HAVING (((IsNull([tblAllocation_Hist].[dtSentDate]))=True))
ORDER BY tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number;
my problem is when I use the filter on the subform, it is returning all
data, see below (tblAllocation_Hist_subform.Form.Filter is my subform, the
user can enter either an invoice date or number to search):
If IsNull(Me.txtInvoiceDate) = False And IsNull(Me.txtInvoiceNumber) = True
Then
dtDate = Format(Me.txtInvoiceDate, "mm-dd-yyyy")
strWhere = strWhere & "([Invoice_Date]) = #" & dtDate & "#" & " AND "
Else
If IsNull(Me.txtInvoiceDate) = True And IsNull(Me.txtInvoiceNumber) =
False Then
strWhere = "([Invoice_Number]) = " & Chr$(34) & Me.txtInvoiceNumber
& Chr$(34)
End If
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No records found.", vbInformation, "No records found."
Else
strWhere = Left$(strWhere, lngLen)
Me.tblAllocation_Hist_subform.Form.Filter = strWhere
Me.tblAllocation_Hist_subform.Form.Filter = True
End If
It appears that I cannot use a filter on the subform which has as its source
a select statement with a grouping? or is there a different way of doing
this?
statement is is using a group by, here is the coding:
SELECT tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number
FROM tblVendor_Acct INNER JOIN (tblVendor INNER JOIN tblAllocation_Hist ON
tblVendor.Vendor_ID = tblAllocation_Hist.Vendor_ID) ON
(tblVendor_Acct.Vendor_ID = tblVendor.Vendor_ID) AND
(tblVendor_Acct.Vendor_Acct_ID = tblAllocation_Hist.Vendor_Acct_ID)
GROUP BY tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number
HAVING (((IsNull([tblAllocation_Hist].[dtSentDate]))=True))
ORDER BY tblVendor.Vendor_Name, tblVendor_Acct.Vendor_Acct_Name,
tblAllocation_Hist.Invoice_Date, tblAllocation_Hist.Total_Allocation_Invoice,
tblAllocation_Hist.dtSentDate, tblAllocation_Hist.Invoice_Number;
my problem is when I use the filter on the subform, it is returning all
data, see below (tblAllocation_Hist_subform.Form.Filter is my subform, the
user can enter either an invoice date or number to search):
If IsNull(Me.txtInvoiceDate) = False And IsNull(Me.txtInvoiceNumber) = True
Then
dtDate = Format(Me.txtInvoiceDate, "mm-dd-yyyy")
strWhere = strWhere & "([Invoice_Date]) = #" & dtDate & "#" & " AND "
Else
If IsNull(Me.txtInvoiceDate) = True And IsNull(Me.txtInvoiceNumber) =
False Then
strWhere = "([Invoice_Number]) = " & Chr$(34) & Me.txtInvoiceNumber
& Chr$(34)
End If
End If
lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No records found.", vbInformation, "No records found."
Else
strWhere = Left$(strWhere, lngLen)
Me.tblAllocation_Hist_subform.Form.Filter = strWhere
Me.tblAllocation_Hist_subform.Form.Filter = True
End If
It appears that I cannot use a filter on the subform which has as its source
a select statement with a grouping? or is there a different way of doing
this?