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?

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]

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

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.

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

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

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