Results 1 to 4 of 4
  1. #1
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47

    Angry vba to set 2 fields in a controlsource of a textbox

    Hi all,

    I have a table1 which contains last and first names, in a form1 i want to list all the first and last names plus the full name respectively, i just have the problem in putting together the full name (first & " " & last) with textbox's ControlSource, it returns error #names?, please help



    Here is the file concerned Database1.accdb

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    The attached db does what you require but why are you using an unbound form. I have shown how to do this in frmName by concatenating the two columns in the query that the form is bound to.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    zx3 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Aug 2011
    Posts
    47
    Thanks Bob, your file helps a lot, and now i learnt a new way of doing of it other than the one i used to.

    Have a nice day



  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Another trick to concatenating names or other strings is to use the law of propagating nulls.
    If you had a table with a first name, middle name, last name, and a suffix you may not have one or more of those fields in each record but you want to display it if it is there. If you were to concatenate - firstname & " " & middlename & " " & lastname & " " & suffix, and you had no middle name there would be an extra space where the middle name would go.

    if you use L.O.P.N. then you would write it - (firstname + " ") & (middlename + " ") & (lastname) & (" " + suffix)
    Each segment of the string that are enclosed in parenthesis is evaluated separately.
    A null plus anything is still null.
    So if you add (+) the field to the empty space (" ") and the field is null, that segment is a null with no space.


    hope this makes sense.

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

Similar Threads

  1. Textbox ControlSource Issue
    By RonL in forum Forms
    Replies: 12
    Last Post: 11-06-2015, 10:56 AM
  2. Replies: 3
    Last Post: 04-01-2015, 09:46 AM
  3. Replies: 4
    Last Post: 12-09-2014, 02:01 AM
  4. ControlSource problem
    By akhmadahdiyat in forum Programming
    Replies: 3
    Last Post: 11-29-2013, 12:06 PM
  5. Textbox ControlSource Question
    By RonL in forum Forms
    Replies: 4
    Last Post: 02-16-2013, 12:18 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