3251 Error

WVGhostDog
10-14-2004, 07:23 AM
I received a 3251 error for the following statement

rsDetails.Sort = "IssueBaseAuditAutonumber, StampClass"

I have changed between ADO 2.5, 2.6, and 2.7 as references and that doesn't help. I have used code to add and delete records from this table (it is not the recordsource for the form I am implementing this on) and have had no problem. Is there another provider I need to add as a reference?

Thanks, Bob

Shurik12
10-14-2004, 08:25 AM
Why just not open a recordset which already contains sorted data?


.....ORDER BY ssueBaseAuditAutonumber,StampClass

WVGhostDog
10-14-2004, 08:39 AM
Well, I could do that with the Form_Current event, but I will have to add, modify and delete records with a command button and to do that I will have to search the table repeatedly. Below is the code for the Form_Current event, it worked fine until I added the sort. Thanks.

Why just not open a recordset which already contains sorted data?


.....ORDER BY ssueBaseAuditAutonumber,StampClass



Private Sub Form_Current()

Dim rsBase As ADODB.Recordset
Dim rsDetails As ADODB.Recordset
Dim IssueBaseAuditAutonumber As Long
Dim BaseRecordCount As Integer
Dim A As Integer
Dim B As Integer
Dim I, N, P, RG, RB, U, V, X, XJ, E, EE, F, H As Integer
Dim K, NN, RRG, RRB, UU, VV, WW, A1 As Integer
Dim DS, O, OO, MW, CS, CSLE, XXJ As Integer
Dim RecordFound As Integer
Dim AutonumberMatch As Integer



If Not txtAuditAutonumber.Value Then
IssueBaseAuditAutonumber = txtAuditAutonumber.Value
End If

'Set default value for the stamp class text boxes
txtA.Value = 0
txtB.Value = 0
txtI.Value = 0
txtN.Value = 0
txtP.Value = 0
txtRG.Value = 0
txtRB.Value = 0
txtU.Value = 0
txtV.Value = 0
txtW.Value = 0
txtX.Value = 0
txtXJ.Value = 0
txtE.Value = 0
txtEE.Value = 0
txtF.Value = 0
txtH.Value = 0
txtK.Value = 0
txtNN.Value = 0
txtRRG.Value = 0
txtRRB.Value = 0
txtUU.Value = 0
txtVV.Value = 0
txtWW.Value = 0
txtA1.Value = 0
txtDS.Value = 0
txtO.Value = 0
txtOO.Value = 0
txtMW.Value = 0
txtCS.Value = 0
txtCSLE.Value = 0
txtXXJ.Value = 0







Set rsDetails = New ADODB.Recordset

'rsDetails.CursorLocation = adUseClient
rsDetails.Open "tblIssueDetails", CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic, adCmdTable


'rsDetails.Sort = "IssueBaseAuditAutonumber, StampClass"
'rsDetails.Index = "StampOrderFormEdit"


'Check for A stamp value in detail table
'Then repeat for every other stamp quantity text box

Do Until rsDetails.EOF
RecordFound = 0
If IssueBaseAuditAutonumber = rsDetails.Fields("IssueBaseAuditAutonumber") Then
If rsDetails.Fields("StampClass") = "A" Then
txtA.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
'Insert other stamp classes after this comment
If rsDetails.Fields("StampClass") = "B" Then
txtB.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "I" Then
txtI.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "N" Then
txtN.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "P" Then
txtP.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "RG" Then
txtRG.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "RB" Then
txtRB.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "U" Then
txtU.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "V" Then
txtV.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "W" Then
txtW.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "X" Then
txtX.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "XJ" Then
txtXJ.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "E" Then
txtE.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "EE" Then
txtEE.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "F" Then
txtF.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "H" Then
txtH.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "K" Then
txtK.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "NN" Then
txtNN.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "RRG" Then
txtRRG.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "RRB" Then
txtRRB.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "UU" Then
txtUU.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "VV" Then
txtVV.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "WW" Then
txtWW.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "A1" Then
txtA1.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "DS" Then
txtDS.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "O" Then
txtO.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "OO" Then
txtOO.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "MW" Then
txtMW.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "CS" Then
txtCS.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "CSLE" Then
txtCSLE.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
If rsDetails.Fields("StampClass") = "XXJ" Then
txtXXJ.Value = rsDetails.Fields("IssueQuantity")
RecordFound = 1
End If
rsDetails.Sort = "IssueBaseAuditAutonumber, StampClass"
End If
rsDetails.MoveNext
rsDetails.Sort = "IssueBaseAuditAutonumber, StampClass"
Loop

rsDetails.Close
Set rsDetails = Nothing

End Sub

MKoslof
10-15-2004, 08:16 PM
Shurik is absolutely correct, in that you will get much better performance by using an SQL Statement and the ORDER BY clause.

The sort property of the recordset object only works with client-side Recordsets(when implmenting ADO technology). Set the CursorLocation property of the ADO recordset object to adUseClient before trying to implement a sort command.

And I would advise switching your command parameter to adCmdText, and do a standard "SELECT * FROM TableA" query declaration as well.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum