Marshall Brooks
Member
- Local time
- Today, 12:10
- Joined
- Feb 28, 2023
- Messages
- 707
I have a query that extracts records from a table that match a field in the current record on a form.
I use Dcount to tell if the query has any results, like this, and it works fine, but I would prefer to use Ecount:
Ecount works with other queries, but in this case, if I use Ecount, I get "Too few parameters; Expected one".
I saw https://allenbrowne.com/ser-66.html that the code with not work with a reference to a form in the arguments.
The WHERE clause in my query is:
If I change this to:
I don't get the error with Ecount, but I also don't get any query results, b/c the query is looking for a field in the table with the actual text Forms!Form_A.Reference, not the value of the field.
If I change this to:
The query works, but I still get the same error if I try to use Ecount.
If I change this to:
I get hundreds of inaccurate results for the query, and I'm not sure if I get the error or not.
I'm hoping someone sees something I'm missing and can resolve the error message!
I use Dcount to tell if the query has any results, like this, and it works fine, but I would prefer to use Ecount:
Code:
If DCount("EVENT", "qryAuditLog") = 0 Then
Ecount works with other queries, but in this case, if I use Ecount, I get "Too few parameters; Expected one".
I saw https://allenbrowne.com/ser-66.html that the code with not work with a reference to a form in the arguments.
The WHERE clause in my query is:
Code:
WHERE tblAuditLog.REFERENCE= [Forms]![Form_A].[REFERENCE]
If I change this to:
Code:
WHERE tblAuditLog.REFERENCE= """ & [Forms]![Form_A].[REFERENCE] & """
I don't get the error with Ecount, but I also don't get any query results, b/c the query is looking for a field in the table with the actual text Forms!Form_A.Reference, not the value of the field.
If I change this to:
Code:
WHERE tblAuditLog.REFERENCE= "" & [Forms]![Form_A].[REFERENCE] & ""
The query works, but I still get the same error if I try to use Ecount.
If I change this to:
Code:
WHERE "tblAuditLog.REFERENCE= "" & [Forms]![Form_A].[REFERENCE] & """
I get hundreds of inaccurate results for the query, and I'm not sure if I get the error or not.
I'm hoping someone sees something I'm missing and can resolve the error message!