Results 1 to 4 of 4
  1. #1
    sarahji is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    6

    Populating a new field based on another field

    Hi all,

    I just merged two tables into one, and I want to add a field that distinguishes records from the first table and the second one. So I want the new field to have one value for all records with primary keys lower than X and another value for those above X.

    Eg:


    New field: VisitType
    For primary keys 1 - 473325: value will be "Survey"
    For primary keys 473326 - 534582: value will be "Complaint"

    Any suggestions on how to do this?

    Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Try an update query:

    UPDATE TableName
    SET VisitType = IIf(KeyFieldName < 473326, "Survey", "Complaint")
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    sarahji is offline Novice
    Windows 7 Access 2007
    Join Date
    Jun 2010
    Posts
    6
    Success! Thanks, Paul!

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,522
    Happy to help!
    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: 3
    Last Post: 07-12-2011, 02:02 PM
  2. Replies: 5
    Last Post: 01-20-2011, 11:36 PM
  3. Replies: 7
    Last Post: 11-26-2010, 07:54 PM
  4. Selecting a corresponding table field based on text field.
    By michaeljohnh in forum Programming
    Replies: 5
    Last Post: 10-08-2010, 10:33 AM
  5. Populating attachment field based on text box
    By justinwright in forum Forms
    Replies: 16
    Last Post: 09-22-2010, 08:38 AM

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