Results 1 to 5 of 5

Thread: [RESOLVED] max number

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] max number

    Hi i am having a field empno as nvarchar that starts like "IF002"
    I want to auto increment this while i insert each time a record by vbcode

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: max number

    if the field follows the same structure.. meaning
    IF001
    IF002
    IF003
    etc..

    using MAX will work to get it

    SELECT MAX(empno) etc....

    then just cut and add
    tmp = rs.fields(0)
    tmp = left(tmp,2) & (Format(Cint(right(tmp,3))+1,"00#")
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: max number

    The order will be
    IF001
    IF002........IFXXXX

    Will it work for Nvarchar in MSSqlserver

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: max number

    it works in access with text which is basically the same thing...
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: max number

    Thanks Static , I check and come back

Posting Permissions

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



Click Here to Expand Forum to Full Width