Counting number of records in form

R

Red

Can anyone suggest the code that should be used to count
the number of records in a form that contains a certain
value based on a filter run within that form?

I've tried using the code below but it returns 0:

RecCount = DCount("[FieldName]", "QueryName", "FilterValue")

Thanks in advance.
 
R

RobFMS

The format should be something like this:

Forms!<MainFormName>!<SubFormName>.Form.Recordsetclone.Recordcount.

Such that:

If Forms!<MainFormName>!<SubFormName>.Form.Recordsetclone.Recordcount = 0
Then
Msgbox Prompt:="There are no records to display."
End If

HTH

---

Rob

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Need to launch your application in the appropriate version of Access?
http://www.fmsinc.com/Products/startup/index.asp

Need software tools for Access, VB, SQL or .NET?
http://www.fmsinc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 
R

Red

Thanks, that works perfectly.

Wayne Morgan said:
Try Me.Recordset.Recordcount

--
Wayne Morgan
Microsoft Access MVP


Red said:
Can anyone suggest the code that should be used to count
the number of records in a form that contains a certain
value based on a filter run within that form?

I've tried using the code below but it returns 0:

RecCount = DCount("[FieldName]", "QueryName", "FilterValue")

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top