I am attempting to set a filter on a subform using Filter and FilterOn. Below
is the SQL for that subform. If I leave "DISTINCT" out of the SQL, the filter
on the subform will work (no errors) but it does not return the records
correctly. If I add DISTINCT back into the SQL statement then I get an error.
Run-time error '2001' you canceled the previous operation. If I leave the
DISTINCT in the SQL statement and comment out the DCount portion 'CkIt' then
I do not get the error but I also do not get the results I am looking for. Is
there a way to do a SELECT DISTINCT and be able to use DCount also?
CODE
SELECT DISTINCT PQuoteDetails.OrdersID, PQuoteDetails.ProductID, Products.
VendorsID, IIf(IsNull([FundingID]),0,DCount("ProductID","qryRCandProduct",
"FundingID=" & Forms.[frmPQ].[txtFundingID] & " AND RCodeID=" &
[qryReimbursePQ].[RCodeID] & " AND OrdersID=" & Forms.[frmPQ].[OrderID])) AS
CkIt, IIf([FundingID]<>Forms.[frmPQ].[txtFundingID],0,[ReimbursementAmount])
AS RCAmt, qryReimbursePQ.RCodeID, qryReimbursePQ.ReimbursementCode,
qryReimbursePQ.FundingID, qryReimbursePQ.ReimbursementAmount, Products.
ProductDesc, PQuoteDetails.Quantity, Products.PartNumber, Products.
RetailAmount, PQuoteDetails.Note, [Quantity]*[RetailAmount] AS LTotal
FROM (PQuoteDetails LEFT JOIN Products ON PQuoteDetails.ProductID = Products.
ProductID) LEFT JOIN qryReimbursePQ ON Products.RCodeID = qryReimbursePQ.
RCodeID;
Just in case it helps out below is the code behind the cmdButton to filter
the subform
Forms![frmPQ].Requery
Forms![frmPQ]![sfrmPQDetails].Form.RecordSource = "qryRCandProduct" 'Here is
where it points when the error occurs
Forms![frmPQ]![sfrmPQDetails].Form.Filter = "FundingID =" & Forms![frmPQ]!
[txtFundingID] & " Or FundingID Is Null Or CkIt = 0"
Forms![frmPQ]![sfrmPQDetails].Form.FilterOn = True
TIA,
Shane
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201005/1
|
|
0
|
|
|
|
Reply
|
shanesullaway
|
5/9/2010 8:25:05 PM |
|
|
0 Replies
235 Views
(page loaded in 0.018 seconds)
Similiar Articles: DCOUNT ( DISTINCT - microsoft.public.access.queriesWe all know that Dcount doesn't support DISTINCT in VBA ... unique records in a field within ... now looks like this: =DCount([Task ID],[Tasks],"[Task ID] IN (SELECT DISTINCT ... Help with counting distinct records! - microsoft.public.access ...I've had success using DCount() to get ... guests and Services for a period SELECT DISTINCT ... do I count only the unique records within each ... set to retrieve the distinct ... Count distinct lines in a report - microsoft.public.access.reports ...... takes the same arguments as DCount(), but an extra flag you can set > to retrieve the distinct count. ... There can be ... SELECT COUNT(DISTINCT column_name) FROM table_name ... count the number of unique records in a field within Access ...... extends the functionality of the DCount ... so you have to build a Distinct query and then count SELECT Count ... of unique records in a field within Access ... How can I ... Counting Unique Values within a Group - microsoft.public.access ...DCount is giving me the count ... but an extra flag you can set to retrieve the distinct ... Two uses the SAVED query SELECT Range, Count ... Counting Unique Values within ... Invalid Argument (error 30001) - microsoft.public.access.queries ...Cheap. Pick two. Keith Bontrager - Bicycle Builder. "pon" wrote: > > SELECT DISTINCT TST.TST_RUCL_CODE, TST.TST_DOC_CODE ... You may have to do the work > > > > within ... Printing only selected records - microsoft.public.access ...Dan, You can store your choices within a table in Access and join with the ... to specify "distinct": insert into {Name of Access table} (Employee) select distinct ... Count of Unique Values in Access Field - microsoft.public.access ...In the query given below which is done in Access SELECT ... COUNT(*) FROM (SELECT DISTINCT ... of unique records in a field within Access ... How can I ... Dropdown for Inside Address in letter headers - microsoft.public ...I have seen this done before so I know it's possible ... Select the Avery US Letter Vendor from the dropdown list ... Dcount Group by issue - microsoft.public.access.queries ... Ranking scores within a subset of records - microsoft.public ...SELECT [Test Rank].Twirler, [Test Rank].[Entry ID], [Test Rank].Score, [Test Rank].Judge, 1+DCount("*","Test ... with the distinct count of clients per employee within ... DCount Function - Access - Office.com - Microsoft Corporation ...You can use the DCount function to determine the number of records ... when you must count records in a domain from within ... For more information about working with VBA, select ... Access Blog - Writing a Count(Distinct) Query in AccessAs I understand it, the Count(Distinct) here can be used as a test ... it easier to use a saved query, qryColorSums, within another query for this: qryColorSums = SELECT ... [SOLVED] Count Distinct Values? - Excel Help ForumFor example, I can pull the data into Access and use a select query to "group by ... But I need to get the answer within Excel ... I need to determine the number of distinct ... Mixing DISTINCT and COUNT in an SQL - OutFront Webmaster ForumsSELECT DISTINCT Count(' SubCategory' ) AS [Total] FROM SubCategories SELECT DISTINCT ... 6- Click inside the new field, and type " LLL" 7- Highlight LLL in the new ... Distinct Values FunctionDistinct Values Function. This page describes a VBA Function ... The function can be called from an array entered range ... End If NumDims = NumberOfArrayDimensions(Arr) Select ... 7/26/2012 10:25:21 PM
|