472,805 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

displaying record count in a message box

Hi,

I need to be able to display a count of records in a message box but
with a criteria of the just ones where there is a yes in a certain
field. so the message box will pop up saying something like "there are
23 forms issued"

I've got no idea how to do this. been reading about dcount and
experimenting with it but getting no where. Can you help??

Paul

Mar 1 '07 #1
5 20607
LTotal = DCount("SomeField", "SomeTable", "SomeOtherField = 'Yes'")

Msgbox "There are " & LTotal & " forms issued"

Please remember to thank those who help you, as so few others have.

On Mar 1, 10:38 am, Marshall...@gmail.com wrote:
Hi,

I need to be able to display a count of records in a message box but
with a criteria of the just ones where there is a yes in a certain
field. so the message box will pop up saying something like "there are
23 forms issued"

I've got no idea how to do this. been reading about dcount and
experimenting with it but getting no where. Can you help??

Paul

Mar 1 '07 #2
On 1 Mar, 16:04, "ManningFan" <manning...@gmail.comwrote:
LTotal = DCount("SomeField", "SomeTable", "SomeOtherField = 'Yes'")

Msgbox "There are " & LTotal & " forms issued"

Please remember to thank those who help you, as so few others have.

On Mar 1, 10:38 am, Marshall...@gmail.com wrote:
Hi,
I need to be able to display a count of records in a message box but
with a criteria of the just ones where there is a yes in a certain
field. so the message box will pop up saying something like "there are
23 forms issued"
I've got no idea how to do this. been reading about dcount and
experimenting with it but getting no where. Can you help??
Paul- Hide quoted text -

- Show quoted text -

Thanks! That works but its a little slow, takes around 2 mins to show
the message box. Any ideas why?

Mar 1 '07 #3
<Ma*********@gmail.comwrote in message
news:11**********************@30g2000cwc.googlegro ups.com...
Hi,

I need to be able to display a count of records in a message box but
with a criteria of the just ones where there is a yes in a certain
field. so the message box will pop up saying something like "there are
23 forms issued"

I've got no idea how to do this. been reading about dcount and
experimenting with it but getting no where. Can you help??

Paul
Something like this (untested):

Dim intCount As Integer
intCount = DCount("FieldName","tblMyTable","[MyField] = 'Yes'")
MsgBox "There are " & intCount & " forms issued."

HTH - Keith.
www.keithwilby.com
Mar 1 '07 #4
Hi Paul,

Your scenario is a little vague, so I will set up a scenario. On a
standard form you have a button. In the button click event you will
display a messagebox that will show the count of rows from tbl1 where
the YesNo field is yes.

Private Sub command1_click()
Dim i As Integer
i = Dcount("YesNo", "tbl1", "YesNo = -1)
MsgBox "The count of rows where YesNo is Yes is " & i
End Sub

Note: For YesNo fields the actual values are either -1 (=Yes) and 0
(=No)

In the Dcount function you first enter the field you want to query and
surround it with double quotes - in our case it is the YesNo field, then
enter the table which contains this field and surrount it by double
quotes. Then enter the critieria. In this case you want to count the
rows where the value of the YesNo field is -1 (Yes) and surround the
criteria with double quotes.

Now you can click your button and bring up the messagebox with the count
of rows.
MsgBox "The Count of rows from tbl1 where YesNo is yes is " & i
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Mar 1 '07 #5
Basically, it's going record by record and checking to see if it
should be included in the DCount. My guess is that you need to put an
index on the table. That should speed it up a little.

On Mar 1, 11:16 am, Marshall...@gmail.com wrote:
Thanks! That works but its a little slow, takes around 2 mins to show
the message box. Any ideas why?

Mar 1 '07 #6

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

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
2
by: Deamond | last post by:
Hi I have a Table with Automatic ID numbers... In access I delete All records by hand When I add new record with delphi (SQL) the number ID of record count begin with last record+1 and not with...
3
by: thomasp | last post by:
I am trying to get a record count of a PHP query on a MS Acess database using ODBC with a DSN for MS ACCESS connection. I got this code from the PHP manual user notes. It seems to return the...
1
by: Ryan | last post by:
I've got a problem I have't run up against before. I generally test for an empty recordset using BOF and EOF. Today, for the first time I ran into a problem where my recordset shows BOF and EOF =...
6
by: Kulwinder Sayal | last post by:
Hi In ASP it was so simple to get the no. of records using RecordCount. Can anyone help me how to write the no. of records my sqlquery has searched Thanks Kulwinder
1
by: darrel | last post by:
I'm trying to whip up a fancy repeater control that will put records into a two-column table for me. This is how I envision it working: itemtemplate if record count = odd then write out the...
4
by: darrel | last post by:
I have a repeater that I'd like to apply some logic to, namly highlighting the top few items in the repeater. To do this, I need to determine the record count. I've tried this: <% dim...
4
by: Peter W Johnson | last post by:
Hi guys, I have a problem with a datagrid record count. Here is the code:- <snip> Public Class frmMerchantDeposit Inherits System.Windows.Forms.Form Dim myconnection As New...
2
by: John | last post by:
Hi I am using the below statement; Me.MyTableAdapter.Fill(Me.MyDataSet.tblMyTable) How can I now check the record count of the data table and specifically if the record count returned by...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.