Results 1 to 5 of 5
  1. #1
    Jay Pee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    12

    Post Copy only the first 2 characters of a post code

    Dear all,



    In a table containing customer addresses I have several fields, among which are the post code in the format of 4 integers, a space, and 2 letters (Dutch format, e.g. 2258 BG). However, for an indication of regions I want a column next to the post code which automatically gives me the first 2 characters (so only integers in this case) of the post code.

    I was thinking to use the = expression and simply copy the post code in the new column and then apply a trim to only show the first 2 characters, but after setting the expression to fill the new column I seem to be severely limited in my options to alter the column's format. How do I manage this?

  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,722
    You can get the first 2 characters from post code:

    Left(PostCode,2)

    Since you do NOT do arithmetic with a post code, you should treat itas string data.
    If you need a numeric sort you can use CInt(Left(PostCode,2))

  3. #3
    Jay Pee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    12
    Totally forgot to mention you helped me out with this.

  4. #4
    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,722
    So it's all working now?

  5. #5
    Jay Pee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2014
    Posts
    12
    Yes I made an update query to transform and recode the 6 character postcode into the first 2 digits only in an adjacent column. That way I have both the original postcode and a way to appoint customers to a geographic region. I've mapped the query to run as soon as the full postcode field looses focus and the field is set to only accept complete postcodes.

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

Similar Threads

  1. Replies: 3
    Last Post: 05-26-2013, 03:07 PM
  2. Replies: 9
    Last Post: 02-11-2013, 03:09 PM
  3. Replies: 7
    Last Post: 05-03-2012, 06:00 PM
  4. Code to copy data from one field to another?
    By graffiti in forum Programming
    Replies: 1
    Last Post: 12-01-2011, 11:13 AM
  5. Copy Database Code Error
    By Tomfernandez1 in forum Programming
    Replies: 5
    Last Post: 05-03-2011, 12:21 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