Results 1 to 4 of 4

Thread: [RESOLVED] Access Group By

  1. #1

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Resolved [RESOLVED] Access Group By

    I have a table called Requests and I'd like to return values grouped by a field named 'Sentdate'. I tried the following but got a recordcount of -1. What am I doing wrong?

    rs.Open "SELECT count(*) FROM Requests group by SentDate", cn, adOpenDynamic, adLockOptimistic

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Access Group By

    1) your field needs an alias...
    2) since your field isn't aliased, I assume that by "recordcount" you mean the recordset.RecordCount ... a value of -1 is actually good... that means there is at least one record... but it hasn't been returned yet... you're using a Dynamic recordset... means it'll grab records on demand as you move to the next record...
    3) you may want to also return SentDate... otherwise you're just going to get a string of numbers, with no context.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Access Group By

    Okay I did this. How do I display the count?


    .Open "SELECT count(*), SentDate FROM Requests group by SentDate", cn, adOpenDynamic, adLockOptimistic
    .MoveFirst
    Do While Not .EOF
    MsgBox rs.Fields("SentDate")
    MsgBox rs.Count '???
    Loop

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width