0

I currently have the following code

Data1.Recordset.Sort = ("Barcode ID DEC")

In which i want to sort all the Barcode ID records in Descending order. The barcodes have leading zero's which i think may be the problem. For example 00000055. Any suggestions?

2
Contributors
8
Replies
9
Views
5 Years
Discussion Span
Last Post by ChrisPadgham
0

for a start shouldn't it be DESC not DEC and

if you are talking to MS SQL Barcode ID cannot have a space in it, eg BarcodeId
if you are talking to MSAccess then it needs to be inclosed in square brackets [Barcode ID]

0

Thanks for the reply, so Data1.recordset.sort [Barcode ID DESC] or Data1.recordset.sort = [Barcode ID DESC]

0
Data1.Recordset.Sort ["Barcode ID DESC"]
Do Until Data1.Recordset.EOF
    HE = Data1.Recordset("Barcode ID")
    MsgBox HE
    Data1.Recordset.MoveNext
Loop

I've tried multiple variations of the first line, what is wrong, if i have [ ] its says Compile error, external name not defined.

0

the square brackets should be around the fieldname

Data1.Recordset.Sort ("[Barcode ID] DESC")
Do Until Data1.Recordset.EOF    
   HE = Data1.Recordset("[Barcode ID]")    
   MsgBox HE    
   Data1.Recordset.MoveNext
Loop
0

Same error again, thanks for the help i'll just hardcode some other stuff in instead.

0

.sort is not support by all ADO, perhaps it is simpler to put the sort in the SQL

stSQL = "SELECT [Barcode ID] FROM Barcode ORDER BY [Barcode ID]"

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.