KenHigg said:Can you post a sample string and what pc you are trying to get out of it?
Edit: Otherwise, I think it's these: ';' - Maybe they should be ',' ???
KenHigg said:So with '1.1.1.1', InStr(1,[MinuteCode],".") should give you 2 and then you subtract 1 and it gives you 1.
Then you take that and plug it into:
Mid([MinuteCode],1,1)
Which should look something like:
Mid("1.1.1.1",1,1)
This should give you 1
Hum...
Expr1: Mid([MinuteCode],1, cint(InStr(1,[MinuteCode],"."))-1)
???
KenHigg said:Can you simply val() it and then sort as a number?
Something like:
val([MinuteCode])
KenHigg said:Other than readablity, is there some other reason you need it to sort differently?
KenHigg said:A bit off topic (your problem ), Is a minute, when used as you are posting it, some kind measurement or reference?
KenHigg said:So the first item may be topic 1. Then under that you may have sub item 1 and 2 etc. This would be listed as 1.1, 1.2, etc?
(I don't guess I've ever been to a meating, unless you include the ones where I took my 30.06 rifle, but I don't really see any need to take notes - Just aim and fire )
Public Sub Sortem(ptbl As String, pfld As String)
'*******************************************
'Purpose: Create a unique sort
'Coded by: raskew
'Inputs: call Sortem("Table1", "MinuteCode")
'Output: Correct sort order.
'Re: [url]http://www.access-programmers.co.uk/forums/showthread.php?t=95572[/url]
'*******************************************
Dim db As Database
Dim rs As Recordset
Dim n As Integer
Dim intHold As Integer
Dim strKeep As String
Dim strSQL As String
Set db = CurrentDb
Set rs = db.OpenRecordset(ptbl)
Do While Not rs.EOF
strKeep = rs(pfld)
For n = 1 To 5
If InStr(strKeep, ".") > 0 Then
intHold = Val(Left(strKeep, InStr(strKeep, ".") - 1))
strKeep = Mid(strKeep, InStr(strKeep, ".") + 1)
Else
intHold = Val(strKeep)
strKeep = ""
End If
rs.Edit
rs(Choose(n, "a", "b", "c", "d", "e")) = intHold
rs.Update
If Len(Trim(strKeep)) = 0 Then Exit For
Next n
rs.MoveNext
Loop
rs.Close
strSQL = "SELECT Table1.MinuteCode, Table1.SortOrder" _
& " FROM Table1" _
& " ORDER BY Table1.a, Table1.b, Table1.c, Table1.d, Table1.e;"
Set rs = db.OpenRecordset(strSQL)
n = 1
Do While Not rs.EOF
With rs
.Edit
!SortOrder = n
.Update
End With
n = n + 1
rs.MoveNext
Loop
rs.Close
db.Close
Set db = Nothing
End Sub