invalid procedure call (1 Viewer)

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
why aint this working ?

Expr1: Mid([MinuteCode];1;InStr(1;[MinuteCode];".")-1)
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
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 ',' ???
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
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 ',' ???
nah, when i make them "," it says i have placed iligal comma's
The weird thing is that when i split the expressions, it does work. When i join them , they dont.


im trying to get 1.1.1.1
for example
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
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)

???
 
Last edited:

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
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)

???
ok, running to fast atm!

im writing a sort function.

i want to sort a texttype key.
the occurences are

1
1.1
1.2
2
2.1
2.2
...
12.1
12.2

the problem is as you sort as a teksttype, it wil put 12 above 2.
Thats why i want to split it and make it numbers.
THis is the only way i can think of!
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
Can you simply val() it and then sort as a number?

Something like:

val([MinuteCode])
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
KenHigg said:
Can you simply val() it and then sort as a number?

Something like:

val([MinuteCode])

nope.
doesnt work
i needs to go 5 levels deep!
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
Other than readablity, is there some other reason you need it to sort differently?
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
KenHigg said:
Other than readablity, is there some other reason you need it to sort differently?
yes
its a minute!
it goes to customers
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
Sorry to be so thick...

You have a fld named 'MinuteCode'.
It contains a value that has 4 numbers seperated by periods. Something like:

12.1.32.12

What about:

val(replace([MinuteCode],".",""))

And then sort that.

???
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
Thanks for the reply:

This is the result

MinuteCode Expr1
1 1
1.1 11
1.2 12
1.1.1 111
11.1 111
1.12 112
11.2 112
11.4 114
1.2.1 121
12.2 122
13.2 132
2.2.2 222
11.1.1 1111
1.12.2 1122

meaning that 1.1.1 needs to be below 1.1 and not 1.2!
still not there.
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
A bit off topic (your problem :) ), Is a minute, when used as you are posting it, some kind measurement or reference?
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
KenHigg said:
A bit off topic (your problem :) ), Is a minute, when used as you are posting it, some kind measurement or reference?
lol. like when you have a meating, you right down the actions you discuse. those are the minutes
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
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 :))
 
Last edited:

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
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 :))
hehe
and yes that would be the list
 

KenHigg

Registered User
Local time
Today, 04:51
Joined
Jun 9, 2004
Messages
13,309
Do you plan on having a max of four levels? (1.1.1.1)
 

ice-9

Registered User.
Local time
Today, 01:51
Joined
May 21, 2004
Messages
88
i think i fixed it m8
i just used 3 spaces
 

raskew

AWF VIP
Local time
Today, 03:51
Joined
Jun 2, 2001
Messages
2,734
Hi –

1) Add 6 number fields to your table. Title them a, b, c, d, e and SortOrder.

2) Copy Public Sub Sortem, see below, to a new module.

3) From the debug (immediate) window call the procedure, e.g. Call Sortem(“table1”, “minutecode”)

4) Create a query of your table, including whatever fields needed plus SortOrder. Sort on SortOrder.

5) Anytime you make changes to the numbering of your minutes, rerun Sortem()

Tested in Access 97

HTH – Bob

Code:
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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top Bottom