Results 1 to 4 of 4
  1. #1
    djlabreche is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    5

    use update query to add prefix to a field


    Here is what I am attempting: I have a field that needs to be updated with a prefix. Such as "1501" needs to be "UK1501". This needs to occur in this field in every record in the table. This process will need to repeated each time the database is used for a different project...about 20 times a year.

  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,640
    Personally I wouldn't bother to update the field. I'd have the prefix separately somewhere, either in a one-record table or on a form, then concatenate the prefix with the value on the fly. If you want to update the field, you can use an update query, but you'd have to strip off the previous prefix as well, would you not?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    djlabreche is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jun 2014
    Posts
    5
    Actually, I failed to include some key information. The prefix can be any one or two alpha characters. It needs to be entered by the user. The database will be used by each project independently. That is, it will be copied to the new project and the copy be used by that project exclusively.

    However, I will need to give the user the option of changing the prefix so yes I will need to strip it as you mention.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    All the more reason not to save the values together in my mind. I'd have a form for the user to enter the prefix and just concatenate that with the field in your forms/reports. If you really want to save it, use a form for the user to enter the old and new prefixes and use an update query, using the Replace() function to get rid of the old inside a concatenation with the new:

    NewPrefix & Replace(FieldName, OldPrefix, "")
    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: 1
    Last Post: 05-17-2013, 12:53 PM
  2. Replies: 2
    Last Post: 08-30-2012, 07:59 AM
  3. Prefix character in ID field
    By Zbeibu in forum Access
    Replies: 2
    Last Post: 05-14-2012, 07:21 AM
  4. Table naming - use prefix or not?
    By revnice in forum Access
    Replies: 4
    Last Post: 08-08-2010, 11:55 AM
  5. Add prefix to AutoNumber
    By sirmilt in forum Database Design
    Replies: 3
    Last Post: 07-09-2010, 01:41 PM

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