Results 1 to 6 of 6
  1. #1
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42

    Adding additional characters to an existing product number

    The unique product number assigned to each inventory item must be preceded with "V0000" if the existing product number has five characters and "V000" if the existing product number has six characters. I need to make this change to the existing table(s) and to new entries in then future by means of a form.



    I don't know where to start.

    Thank you

    Steven

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    An update query can be used for existing records. An expression like:

    IIf(Len(FieldName) = 5, "V0000", "V000") & FieldName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Use a similar idea for the form

    Code:
    If Len(fieldname)=5 Then
       me.FieldName="V0000" & me.fieldname
    ElseIf Len(FieldName)=6 Then
       Me.FieldName = "V000" & me.FieldName
    Else
    'do nothing 
    End If
    Substitute your field name in the code
    Note that the else if statement prevents the code running again if it's already been applied
    The final Else clause is only there to explain the idea. It can be deleted as it does nothing
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    and to new entries in then future by means of a form.
    Is it possible that in the future, values will be longer than 6 or less than 5?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    streub is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Oct 2017
    Posts
    42
    The recommendations are exactly what I need. I just could not remember the coding terms.

    There may be less than four or more than six in the future but I retire in 18 months. Who cares then?

    Thank you all.

    Steven

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by streub View Post
    I retire in 18 months.
    Lucky bugger.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 02-28-2015, 11:57 AM
  2. Replies: 3
    Last Post: 01-18-2015, 06:05 PM
  3. adding an additional sub table
    By rmayley@puroclean.com in forum Access
    Replies: 1
    Last Post: 06-10-2013, 03:33 PM
  4. Adding additional fields in form
    By ThebigCt in forum Forms
    Replies: 2
    Last Post: 02-23-2012, 12:33 AM
  5. Adding an additional WHERE clause
    By Pells in forum Queries
    Replies: 7
    Last Post: 10-28-2010, 12:44 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