PDA

View Full Version : Command returning -1 records no matter what



asherman86
05-28-2013, 12:14 PM
I have the following code:

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


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. :banghead:

HiTechCoach
05-29-2013, 10:02 PM
Try moving to the last record before getting the record count.

asherman86
05-30-2013, 05:06 AM
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; :dunno 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.