Member Avatar for gowans07

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]

Member Avatar for gowans07

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

Member Avatar for gowans07
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
Member Avatar for gowans07

Invalid Use of property on the first line.

try this


Data1.Recordset.Sort "[Barcode ID] DESC"

Member Avatar for gowans07

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]"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.