recordset.recordcount always shows -1

My record set always returns a -1 when I enter it as a query it returns records.  Why would it not register records in the recordset and register them in the query?
Dim cn As New ADODB.Connection
    Set cn = CurrentProject.Connection
 
    Dim rs As New ADODB.Recordset
    rs.ActiveConnection = cn
 
    rs.Open "SELECT tblDeferalDetails.EventDetailsID, EventDetailsTable.JobReferenceID " & _
            "FROM EventDetailsTable INNER JOIN tblDeferalDetails ON EventDetailsTable.EventID = tblDeferalDetails.EventDetailsID " & _
            "WHERE (((EventDetailsTable.JobReferenceID)= '16080011'));"
    rs.MoveFirst
    Debug.Print rs.RecordCount

Open in new window

ClaudeWalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ashish PatelCommented:
Now try with this.



Dim cn As New ADODB.Connection
    Set cn = CurrentProject.Connection
 
    Dim rs As New ADODB.Recordset
    rs.ActiveConnection = cn
    rs.CursorLocation = adUseClient
   rs.CursorType = adOpenStatic
 
    rs.Open "SELECT tblDeferalDetails.EventDetailsID, EventDetailsTable.JobReferenceID " & _
            "FROM EventDetailsTable INNER JOIN tblDeferalDetails ON EventDetailsTable.EventID = tblDeferalDetails.EventDetailsID " & _
            "WHERE (((EventDetailsTable.JobReferenceID)= '16080011'));"
    rs.MoveFirst
    Debug.Print rs.RecordCount

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mdouganCommented:
Use a cursor type that allows you to MoveLast first, then MoveFirst (I forget what the other options are).  The problem is that the cursor hasn't fetched all the data yet, so, it doesn't know how many records there are.  If you MoveLast, then MoveFirst, it will have retrieved all the data and then your recordcount should be OK.
0
chikenheadCommented:
set nocount off

run that statement
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.