Results 1 to 7 of 7
  1. #1
    lcg001 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2022
    Posts
    2

    Post Concatenating two text boxes on a form and writing to table

    I have a database which uses a form for data entry into an Employees table.
    I would like to concatenate the [First Name] and [Last Name] fields from this form into a [EmployeeID] field, and have this information written to the Employees table when saving and closing the form.




    I've tried setting the default value for the [EmployeeID] field on the form to = [First Name] & " " & [Last Name] but this appears to do nothing to the form or the table.
    The only way I've gotten it to fill in the concatenated info as desired is when I put the expression as the Control Source, but then I get an error that reads "You must enter a value in the Employees.ID field". I can't figure out how to populate the text box and then have it save the information to the table.


    Thanks in advance, I'm a beginner!

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    I would like to concatenate the [First Name] and [Last Name] fields from this form into a [EmployeeID] field, and have this information written to the Employees table when saving and closing the form.
    Do NOT do that. Your form/report recordsource should include both fields whether or not you have controls for those fields (and if you do, you can hide them). A calculated control would show the concatenated values. If you persist you will likely have problems in the future. Also if your table has FName and LName fields, having a field for the combined value is redundant.
    EDIT - an employee ID field should probably be an autonumber pk field anyway. You might want to consider posting a pic of your table relationships if you've created them.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    lcg001 is offline Novice
    Windows 10 Access 2016
    Join Date
    Nov 2022
    Posts
    2
    Click image for larger version. 

Name:	lending library relationships.jpg 
Views:	25 
Size:	98.3 KB 
ID:	49183

    I fudged the table and field names a bit in my original post for simplicity's sake, but I'm using the Lending Library template to manage inventory of employee keys. I've used the Contacts table for employees. I don't think I ever messed around with the relationships of this db. Here's what I've got. Thanks!
    Attached Thumbnails Attached Thumbnails lending library relationships.jpg  

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    I agree with Micron, no reason to do this.

    Calculate concatenation in table or query or textbox.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,799
    I dunno, but I think I'd stop there and forget the template unless you can adequately modify it. The table and field names aren't great and the use of attachment fields is ill advised (and seems unnecessary for tracking keys, but I don't really know). You'd have to provide a good synopsis in order to get any focused advice (e.g. wondering if keys are lent out to employees who belong to other companies, because that's seems to be the case). Due Date is a calculation, which is something you should not store (actually, already suggested this by saying don't concatenate the names). I'm just going to throw all my links at you and get that over with. Ignore them at your own peril! Lots could be said about what you posted but I don't see the point right now if you might review the material and start over. That's what I'd advise.

    Normalization Parts I, II, III, IV, and V
    http://rogersaccessblog.blogspot.com...on-part-i.html
    and/or
    http://holowczak.com/database-normalization/

    Entity-Relationship Diagramming: Part I, II, III and IV
    http://rogersaccessblog.blogspot.com...ng-part-i.html

    How do I Create an Application in Microsoft Access?
    http://rogersaccessblog.blogspot.com...cation-in.html

    Important for success:
    Naming conventions - http://access.mvps.org/access/general/gen0012.htm
    https://www.access-programmers.co.uk...d.php?t=225837

    What not to use in names
    - http://allenbrowne.com/AppIssueBadWord.html

    About Auto Numbers
    - http://access.mvps.org/access/general/gen0025.htm

    The evils of lookup fields - http://access.mvps.org/access/lookupfields.htm
    Table and PK design tips - http://www.fmsinc.com/free/newtips/primarykey.asp
    About calculated table fields - http://allenbrowne.com/casu-14.html
    About Multi Value Fields - https://www.isladogs.co.uk/multivalu...lds/index.html
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    davegri's Avatar
    davegri is online now Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,411
    LendingLibraryMod-davegri-v01.zip

    Here's a somewhat cleaned up version of the template. I've renamed the keys, removed table lookups, fixed most of the macros to convert references from ID to the new key names. Inexplicibly, some of the combo boxes had their column widths set to zero, meaning the combo could never display anything. I never use attachments, but you might, so I left them in.
    It's a better starting point than the virgin template from Microsoft.

    Click image for larger version. 

Name:	mtm.png 
Views:	22 
Size:	18.7 KB 
ID:	49185
    Last edited by davegri; 11-23-2022 at 12:51 AM. Reason: sp

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,919
    Recommend removing spaces and slashes and hyphens from naming convention.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. concatenating data into one text field
    By bethg79 in forum Reports
    Replies: 3
    Last Post: 01-22-2021, 04:27 PM
  2. Writing to a text file and linking table to text file
    By NightWalker in forum Programming
    Replies: 17
    Last Post: 07-21-2020, 04:35 PM
  3. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  4. Replies: 4
    Last Post: 10-14-2012, 03:34 AM
  5. Concatenating (2x unbound into bound text box)
    By justinwright in forum Programming
    Replies: 1
    Last Post: 08-19-2010, 08:11 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