-
i am trying to sort records from a file (12 fields) in order of the first field, but even though it works after clicking the button about ten times, i cant get the damn thing to do it first time without adding another for...next loop, doing this would resolve the problem of the first field sort, but if i want to sort by another field i need to change the loop size.
well heres the code:
->->->->->->->->->->->->->
Function SortRecords(Field)
' This is the sort code, this sorts the records in order of the
'passed parameter.
On Error GoTo ENDOFFUNCTION
If ArrayCounterPF = 0 Then
MsgBox "Norecords to sort!", vbCritical
Exit Function
Else
End If
Do
Sorted = True
For counterx = 1 To ArrayCounterPF
If ArrayDataPF(Field, counterx) > ArrayDataPF(Field, counterx + 1) Then
'"sorting..."
For fieldnumber = 1 To 12
temp = ArrayDataPF(fieldnumber, counterx + 1)
ArrayDataPF(fieldnumber, counterx + 1) = ArrayDataPF(fieldnumber, counterx)
ArrayDataPF(fieldnumber, counterx) = temp
Next fieldnumber
Sorted = False
Else
End If
Next counterx
Loop Until Sorted = True
ENDOFFUNCTION:
End Function
->->->->->->->->->->
the function is call from a list box, when the feild is selected from list box, the index is passed to the function (Field).
Please help, its been bugging me for hours!!!!!
-
Can you re-post the code with all the variables declared so I can so exactly what we're working with.
Please....
-
its ok, i've fixed the problem. i forgot to loop the passesd parameters.