[mso] Re: Counting records in Access with an IF statement

  • From: "Ray Blake" <ray@xxxxxxxxx>
  • To: <mso@xxxxxxxxxxxxx>
  • Date: Fri, 20 Aug 2004 15:44:24 +0100

The easiest way to do this (believe it or not!) is to include a subform
on your form based on a query which selects records based on the value
showing on your main form and you can thereby count records.

It sounds horribly complex and it is! Slowly, though, here are the
steps. I'm assuming tou have a table called tblTable and a form called
frmForm, both of which include your field called first.

Make a new query called qryQuery based on tblTable and including only
one field: first.

In the criteria line, type in: Forms!frmForm!first

Now make a new form called frmSub. Put an unbound text box on it and
enter =count(first) as its data source. Make the form really timy - just
big enough for the new text box.

Now go back to design view of frmForm and insert a subform. Choose
frmSub as the source and say 'none' when it asks you for the linking
basis. 

Done.

Ray

------------------------------------
GR Business Process Solutions
Ray Blake
Head of Software Design
ray@xxxxxxxxx
Braedon
Newell Road
Hemel Hempstead
Herts HP3 9PD
tel: 01442 396518
fax: 01442 389353
www.grbps.com
------------------------------------


-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On
Behalf Of michael.crader@xxxxxx
Sent: 20 August 2004 12:17
To: mso@xxxxxxxxxxxxx
Subject: [mso] Counting records in Access with an IF statement


Dear all,
I have a table and a field called first. I have a form with an unbound
text box. In the properties section, Control Source, I have this code
that counts the records in the field FIRST. This works perfectly.

=Count([first])

Now, what I'd like to do please, is to count the records based on a
criteria, such as MICHAEL

How would the code look - in Excel I'd use a COUNTIF? I was hoping it
was as simple as 

=count([first])="Michael", but this errors.

Many thanks,


> Regards,
> 
> Michael Crader
> 

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx with the word "unsubscribe" (without the quotes) in 
the subject line.

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts: