Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Access String Question (2003)

    I have a variable yearnumber which is the last two digits of the current year. I want to have A05 followed by a three digit number that is incrementing by one. The value in data will be the previous number created, such as A05001. The next number needs to be A05002. How do I get the last tthree digits of the previous entry and increment it to join it with the A05 to get A05002.

    Here is the code I have been trying to use. I think I have problems with the end portion of the code

    txtJob.Value = "A" & yearnumber & (Left(data.ItemData(0), (Len(data.ItemData(0)))) + 1)

    Any help is appreciated.
    Thanks

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Access String Question (2003)

    I don't know what value is in that listbox, but assuming it is correct, this ought to give you what you want:

    txtJob.Value = "A" & yearnumber & format(data.ItemData(0)+1, "000")

    Of course, this doesn't deal with the possibility that the value of data.ItemDate(0) could be >=999, which is one of the reasons such identifiers like what you want to create often create more problems than they solve.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    2 Star Lounger
    Join Date
    Jun 2004
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access String Question (2003)

    Whenever I use the code it gives me a type mismatch error. The value in the listbox is correct when I set up a breakpoint. It is ok because the application will never require a number over 999 in a single year. When the year changes, it will be A06.......

  4. #4
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Access String Question (2003)

    What is the value of data.ItemData(0) ?
    if it is A05001 then the formula should be :
    txtJob.Value = "A" & yearnumber & format(Right(data.ItemData(0),3)+1, "000")
    Francois

  5. #5
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Access String Question (2003)

    You could try this:

    txtJob.Value = "A" & yearnumber & format(cint(data.ItemData(0))+1, "000")
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

Posting Permissions

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