Consulting

Results 1 to 3 of 3

Thread: Command returning -1 records no matter what

  1. #1

    Exclamation Command returning -1 records no matter what

    I have the following code:
    [VBA]
    If Me.cmbWorkgroups.Enabled Then
    With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandText = "vRecsPerBox_withWorkgroup"
    .CommandType = adCmdStoredProc
    .Parameters.append .CreateParameter("wg", adVarChar, adParamInput, 100)
    End With
    cmd.Parameters("wg") = Me.cmbWorkgroups
    Set rs = cmd.Execute
    Debug.Print rs.RecordCount
    Else
    [/VBA]

    When I run the query and just type in the parameter value, it returns plenty of values. When I try to run it from vba, I get -1 no matter what I do.

    Any advice would be helpful.

  2. #2
    Try moving to the last record before getting the record count.
    Boyd Trimmell aka HiTechCoach
    Microsoft Access MVP -2010-2015

    Programming: Nine different ways to do it right, a thousand ways to do it wrong.
    Binary--it's as easy as 1-10-11

  3. #3

    Question Hmmm...

    Well, I tried that, still returns -1;

    Then I moved on to the code that's supposed to iterate through the recordset and lo and behold there be records there O_o; code works fine, as it's supposed to.

    Not sure why I can't get the record count, but I guess if the module works, that is the important thing. If any one can expound upon it and explain why this is the case, that may be good for posterity purposes. I hate to leave a topic resolved, but unexplained.

Posting Permissions

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