Results 1 to 3 of 3
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Mid Text String's Number Bump by One

    I have a text string 'G123-13' that needs to be incremented by one. It's stored as a text string and I can get the value through DLOOKUP, and can see the value if I use the following:

    grow_lic = DLookup("[Licence]", "FULLGROWER")


    licence_mid = Mid(grow_lic, 2, 3)

    But how do you increase the licence_mid value by one and then put the 'G' and '-13' back onto the text string?

    Any help would be appreciated.

    CementCarver

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,847
    What is the business rationale behind this? One of the key concepts of relational database is 1 fact 1 field, and this seems to be trying to build some intelligence into a code/identifier.

    When we usually think of incrementing something by 1 (that is adding 1 to something), the something is usually a number.
    A best your "code" is some text concatenated with a number and the number part can be incremented.

    There is a database at https://skydrive.live.com/?cid=cc4b0...Oz1XZPZFuCucdk that has a sample. I saw it referenced in another post earlier today --regarding custom autonumbers or something similar.

  3. #3
    HMEpartsmanager is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    85
    Quote Originally Posted by CementCarver View Post
    I have a text string 'G123-13' that needs to be incremented by one. It's stored as a text string and I can get the value through DLOOKUP, and can see the value if I use the following:

    grow_lic = DLookup("[Licence]", "FULLGROWER")
    licence_mid = Mid(grow_lic, 2, 3)

    But how do you increase the licence_mid value by one and then put the 'G' and '-13' back onto the text string?

    Any help would be appreciated.

    CementCarver
    Are you not almost there? Can something like:

    grow_lic = DLookup("[Licence]", "FULLGROWER")
    licence_mid = Mid(grow_lic, 2, 3)
    NewLicense = "G" & Str(licence_mid + 1) & "-13"
    Re-write the License back to the table?

    Tim

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-22-2012, 05:33 PM
  2. Replies: 0
    Last Post: 10-22-2012, 02:45 PM
  3. How to Convert string to Number?
    By taimysho0 in forum Programming
    Replies: 1
    Last Post: 02-24-2012, 01:57 PM
  4. Breaking the string into Text / Number
    By Amerigo in forum Queries
    Replies: 15
    Last Post: 05-20-2011, 03:29 PM
  5. I need to remove a dash from a number string.
    By catguy in forum Programming
    Replies: 3
    Last Post: 02-18-2010, 02:56 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums