Results 1 to 3 of 3
  1. #1
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108

    Using two fields in a form to generate a third field

    Hey there, i'm sorry if this is a rookie question i'm still pretty new, but I hope that's what these forums are for! I am using Access 2010.

    I've got a form where I want to add an employee and I have three fields (EmpFirstName), (EmpLastName), and (EmpCode).

    They all have their own control source from a table but what I want is EmpCode to automatically fill in after they type a first name and last name and not be editable.
    Example being. Smith, John and the empcode will fill in with smijo (3 of last and 2 of first). I understand this is probably completed using Expression Builder (not sure on the command) and how do I make it so Empcode still receives the data entered??

    Thanks in advance!

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    use the left function e.g.

    left(lastname,3) & left(firstname,2)

    however your proposal is potentially flawed because you could end up with duplicates

    Smith, John
    Smith, Joe
    Smiley, Joanna

    Also - what happens if Joanna gets married and changes her last name to Brown?

    so before expending energy working out how to do it, consider all the implications and how they will be handled

  3. #3
    redekopp is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2015
    Location
    Saskatoon
    Posts
    108
    Quote Originally Posted by Ajax View Post
    use the left function e.g.

    left(lastname,3) & left(firstname,2)

    however your proposal is potentially flawed because you could end up with duplicates

    Smith, John
    Smith, Joe
    Smiley, Joanna

    Also - what happens if Joanna gets married and changes her last name to Brown?

    so before expending energy working out how to do it, consider all the implications and how they will be handled
    Thanks for your response. That makes sense, I didn't think through the possibilities like that. Will have to revise what im doing. But its good to know how to use that function generally.

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

Similar Threads

  1. Replies: 2
    Last Post: 12-15-2014, 04:53 AM
  2. Using Multiple Fields in Form to Generate Query
    By crawfish124 in forum Forms
    Replies: 4
    Last Post: 06-04-2014, 10:39 AM
  3. Replies: 5
    Last Post: 05-10-2014, 01:14 PM
  4. Replies: 4
    Last Post: 10-30-2012, 06:32 PM
  5. Replies: 2
    Last Post: 06-10-2012, 01:10 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