473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

DCount with a query that uses Like...

Greetings,

I have a form that uses a query as its record source. In the form I
have a text box that uses this as its control source:

=DCount("[ID]", "qry_Search_by_Name")

The DCount function works properly with the query until I add a
criteria to the query like this:

Like "*" & [enter name] & "*"

then the DCount returns #Error

How can I make DCount work when the query uses a criteria this way?

Thank you in advance!
Chas
Apr 2 '06 #1
2 12186
Have the query read the name from the text box on a form.
For example, the Criteria in the query might read:
Like "*" & [Forms].[Form1].][Text0] & "*"

If you already have the name in the form you are working with, you could
use:
=DCount("*", "Table1", "[Surname] Like ""*" & [Text0] & "*""")
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

<ChasW> wrote in message
news:pp********************************@4ax.com...
Greetings,

I have a form that uses a query as its record source. In the form I
have a text box that uses this as its control source:

=DCount("[ID]", "qry_Search_by_Name")

The DCount function works properly with the query until I add a
criteria to the query like this:

Like "*" & [enter name] & "*"

then the DCount returns #Error

How can I make DCount work when the query uses a criteria this way?

Thank you in advance!
Chas

Apr 2 '06 #2
On Sun, 2 Apr 2006 14:25:25 +0800, "Allen Browne"
<Al*********@SeeSig.Invalid> wrote:
Have the query read the name from the text box on a form.
For example, the Criteria in the query might read:
Like "*" & [Forms].[Form1].][Text0] & "*"

If you already have the name in the form you are working with, you could
use:
=DCount("*", "Table1", "[Surname] Like ""*" & [Text0] & "*""")


problem solved, thank you!
Apr 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: selma | last post by:
I am puzzled by visual explain for a simple query ( select * from mytable ) chooses an index scan. That index has only a single column and the table has 30 columns not covered by the index. When...
5
by: Koen | last post by:
Hi all, I created a function that updates a certain status field. The status can be influenced by four different other fields. So, on the form where I edit these fields I call the function (see...
5
by: Jack | last post by:
Hi, I am trying to find rows where a memo field in table1 contains the text in table2. Example: table1.memo contains: row 1: This is a long sentence that goes on and on... row 2: This is...
1
by: Blue Lagoon Products - Customer Services | last post by:
Hi, Here is my expression =DCount("","tblDownload")>2 I would like to know how many records (including this one?) contain the same 'Buyer ID' as that in txtBuyerID on my report, is this...
2
by: markios | last post by:
Hi, Ive got the code working to an extent when comparing the searchterm with an column name, but there is still 2 problems Im having. Initially the LIKE isnt working, Infact if I even enter...
2
Ericks
by: Ericks | last post by:
Why is it that a table's Memo field in a Query behaves like a Text field, showing only the first 255 characters when using the Totals option. When turning off the Totals options all text is shown. I...
3
by: Budsy | last post by:
This is a peculiar problem for me. I am finding that the following query works perfectly and gives the expected result set when used in the Access query design environment, but it simply gives no...
2
by: dan.cawthorne | last post by:
Need Some Help, In Modifing this Bit of VBA Code, This the code i use and it works but i want it to go one step further in on the open event of my main start up form If DCount("",...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.