Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    orange's Avatar
    orange is online now Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Here are 2 ways to get the newname.



    1: Add a field to your existing table
    My test table: I added a new text field called tnewname to the table and left it empty.

    id tname tnewname
    12345600_9101112131415 Sue_S
    12345621_9101112131415 Bob_Q
    12345678_9101112131415 Jack_L


    Then created a Select query QCorr1
    Code:
    SELECT Tcorr1TEST.tname
    , Tcorr1TEST.id
    , Left([id],9) & [tname] AS XX
    FROM Tcorr1TEST;
    With this result
    Code:
    tname      id                             XX
    Sue_S    12345600_9101112131415    12345600_Sue_S
    Bob_Q    12345621_9101112131415    12345621_Bob_Q
    Jack_L    12345678_9101112131415    12345678_Jack_L
    Note: This is a select query to get info from your existing table. You could use this depending on your set up. Or, you could change this to an Update query and popuate the new field in your existing table.

    2: Manipulate your existing table to create a new table with only the fields you need.
    Using your skeleton SQL with my field naming to create TCORR2

    Code:
    SELECT TCORR1Test.ID
    , TCORR1Test.TName 
    , Left(Tcorr1Test.id,9) & TCORR1Test.TName as NewName
    INTO TCORR2
    FROM TCORR1Test;
    Results in

    TCORR2
    ID TName NewName
    12345678_9101112131415 Jack_L 12345678_Jack_L
    12345621_9101112131415 Bob_Q 12345621_Bob_Q
    12345600_9101112131415 Sue_S 12345600_Sue_S

  2. #17
    nicoboss is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Sep 2017
    Location
    http://www.webagency321.com
    Posts
    72
    Quote Originally Posted by orange View Post
    Here are 2 ways to get the newname.

    1: Add a field to your existing table
    My test table: I added a new text field called tnewname to the table and left it empty.

    id tname tnewname
    12345600_9101112131415 Sue_S
    12345621_9101112131415 Bob_Q
    12345678_9101112131415 Jack_L


    Then created a Select query QCorr1
    Code:
    SELECT Tcorr1TEST.tname
    , Tcorr1TEST.id
    , Left([id],9) & [tname] AS XX
    FROM Tcorr1TEST;
    Hi

    First I created a 3rd field in the table named "Name2"
    Here is my code :

    Code:
    SELECT CORR1.Name, CORR1.id
    , Left([id],9) & [tname] AS Name2
    FROM CORR1;
    When I paste it in SQL Direct and run it, an access window pops up asking me to select the input data in windows explorer.
    I think this is nnot normal, so I guess I do it wrong ?

  3. #18
    nicoboss is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Sep 2017
    Location
    http://www.webagency321.com
    Posts
    72
    ah ok, it was not in SQL Direct, sorry

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 17
    Last Post: 11-03-2017, 08:20 AM
  2. Replies: 1
    Last Post: 12-04-2016, 05:43 PM
  3. Replies: 2
    Last Post: 01-03-2015, 07:18 PM
  4. Replies: 5
    Last Post: 04-23-2013, 01:42 PM
  5. update field with specific content
    By luxeon in forum Queries
    Replies: 2
    Last Post: 01-24-2011, 03:29 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