Results 1 to 20 of 23

Thread: Sorting based on letter, and then on number

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,970
    Quote Originally Posted by Tom Jones View Post
    @snb,
    Highlight this line:
    .Fields("S") = Replace(sn(j, 1), .Fields("N"), "")
    I think it's to do with the original ending in a zero. In the following, zzz is your recordset object:
    ?sn(j, 1)
    FVR25180
    ?StrReverse(sn(j, 1))
    08152RVF
    ?Val(StrReverse(sn(j, 1)))
     8152 
    ?StrReverse(Val(StrReverse(sn(j, 1))))
    2518
    ?zzz.Fields("N")
     2518 
    ?Replace(sn(j, 1), zzz.Fields("N"), "")
    FVR0
    I put it in code tags to try to preserve spaces/invisible characters.
    Although the last command produces a string, it's the execution of:
    .Fields("S") = Replace(sn(j, 1), .Fields("N"), "")
    which throws an error.
    Doing a Val on a string starting with zero, the zero is ignored.
    Still don't know why it throws an error though…

    edit: could it be because it's trying to put more than a 3-character string in a field with a defined size of 3?
    Last edited by p45cal; 10-18-2021 at 01:42 PM.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •