Results 1 to 3 of 3
  1. #1
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368

    DCount on filtered subform

    Hi all,



    I'm looking to get a count of records in a filtered subform on my mainform with a specific criterion. I'm not sure how to reference the filtered subform, however.

    DCount("*", "[filtered subform]", "some field = " & someControl)

    I've tried Me.subform.Form.RecordSetClone, ...RecordSet, ...RecordSource

    Help?

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    How about using:
    Code:
    Dim rst As DAO.Recordset
    Dim lngCount As Long
     
    Set rst = Me.subformControlNameHere.Form.RecordsetClone
       Do Until rst.EOF
          If rst![Some Field Name Here] = Me.SomeControl Then
             lngCount = lngCount + 1
          End If
          rst.MoveNext
       Loop
     
    rst.Close
    Set rst = Nothing
     
    Me.SomeControlHere = lngCount

  3. #3
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Thanks. I had a feeling DCount wasn't going to suffice.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-28-2014, 01:15 PM
  2. Displaying filtered data in subform
    By crxftw in forum Forms
    Replies: 11
    Last Post: 06-17-2011, 09:59 AM
  3. Replies: 7
    Last Post: 01-12-2011, 08:59 AM
  4. Replies: 5
    Last Post: 01-02-2011, 10:09 AM
  5. Replies: 0
    Last Post: 12-20-2010, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums