473,395 Members | 1,437 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,395 software developers and data experts.

Form/TextBox/Count Function problem

Lensmeister
I am getting a little better on this Access DB (in Access 2003) I am making although I am having one problem at this time I cannot fathom out.

I have a form (frm_Stats) This form has the following textboxes on it
1. Total Number of Records in the table Matches.
2. Total Number of Records in the table tbl_Players.

Once I get over these I can move on a bit.

OK the problem:

I have the form and the textbox. In the "control source" I have the following Formula which I found on a website:
=Count([Matches])

when I open the form up it shows
#Error

Anyone have any ideas how to overcome this. I have also tried
=Count([tbl_Players])

Again that came up with
#Error

Thanks in advance.
Mar 6 '09 #1
6 10542
Stewart Ross
2,545 Expert Mod 2GB
The #Error message usually arises when you supply a field name that is not recognised as part of the underlying recordset, or when you have accidentally set the name of the unbound control concerned to be the same as an existing field (which would prevent Access from knowing which one to apply).

Simplest answer, since Count does not need a field name, is to set the control source to be

=Count(*)

This will give you a count of the number of records in the recordset underlying your form. However, if you are using an unbound form (one that is not bound to a query or table) you have nothing to count.

If this is the case you can perform a lookup of the count of the number of records in a table by using the DCount function:

=DCount("*", "tbl_Players")

-Stewart
Mar 6 '09 #2
Hi Stewart,

Thanks for that. It is a unbound form. Can I confirm that if I wanted to cont the number of "W" in the table Matches in the column/Field R the formula would be

=Dcount("W","Matches","V") ? ? ? ? ?

Lensmeister.
Mar 8 '09 #3
Stewart Ross
2,545 Expert Mod 2GB
Not quite; DCount (like the Count function) counts the number of rows in the dataset. To count rows that have 'W's (or any other value) in them you need to restrict the rows being counted to be only those where the field or fields concerned have that value. DCount can do this, using its WHERE clause (which is like an SQL WHERE clause without the word WHERE. For a string comparison use the first form of the DCount below, for a number use the second:

Expand|Select|Wrap|Line Numbers
  1. DCount("[name of some field]", "[your table name]", "[field you want to compare] = 'W*'")  ' < string form
  2. DCount("[name of some field]", "[your table name]", "[field you want to compare] = 123456) ' < numeric form
-Stewart
Mar 9 '09 #4
Hi,

I have the Unbound form with a textbox on it.

Expand|Select|Wrap|Line Numbers
  1. =DCount("[R]","[Matches]","[R]"='W')
is in the 'control source'

In the Matches table there are 2 "W" and only 1 "L". in the column/field "R" (R=Result).

When I view the form it comes up with a "0". I tried to remove the 1st and 2nd [R] but they didn't work either.

Am I missing something ?

Lensmeister.
Mar 9 '09 #5
Stewart Ross
2,545 Expert Mod 2GB
If what you have posted is accurate you have the closing double quote in your WHERE clause in the wrong place:

Expand|Select|Wrap|Line Numbers
  1. =DCount("[R]","[Matches]","[R]='W'")
As a piece of advice, give your fields meaningful names. [R] is not in any way intuitive or helpful. It should really just be Result...

-Stewart
Mar 9 '09 #6
Thanks mate ... that works perfect.

the field called R is for result, but it's an old Excel database I set up about 12 years ago and I am used to what each one means .... I am a creature of habit so R was the easiest for me at the time.

I will think about getting it changed once I got my head round this DB ..

Again thanks mate .... :) :) :)
Mar 9 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
2
by: anonieko | last post by:
This applies to javascript dynamic textbox onkey > > > Newsgroups: comp.lang.javascript From: Lasse Reichstein Nielsen <l...@hotpop.com> - Find messages by this author Date: Fri, 15 Jul 2005...
0
by: 42 | last post by:
I implemented a simple class inherited from Page to create a page template. It simply wraps some trivial html around the inherited page, and puts the inherited page into a form. The problem I...
25
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
14
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class...
0
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool...
3
by: hugo | last post by:
Hi, I have a function that I call from form fields using the OnKeyUp function to replace special caracters. Once this function has been called, it does not set the focus on the form field where...
13
JodiPhillips
by: JodiPhillips | last post by:
G'day, I have a silly and simple problem that I need some guidance with. Due to the way our network is set up, I am unable to use the group permissions for Access and have had to implement log...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.