Results 1 to 14 of 14
  1. #1
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36

    need help in form- move text box value to table_name

    here is want i want to do...




    in my form i want to concatenate the first and last name , then display the concatenate value in a textbox called XLONG
    also, when i press a button (ON_CLICK) event. i want the textbox value XLONG moved to the column in my database table.
    Column is called CONCAT_NAME

    Private Sub Command86_Click()
    'XLONG is name of text box on the form'


    xlong = CUST_LNAME & " xxxxxxx " & CUST_FNAME & "-" & CUST_INITIAL & "-" & CUST_PHONE & "...." & CUST_CITY




    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,738
    jker,

    Why do you want to save the concatenated value in your table?
    Since you store CUST_LNAME and CUST_FNAME..., you can easily create the concatenation when needed.

    Where do you plan to use the concatenation?

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,998
    Don't. Just concatenate it when you need it.

    If you insist, just make ConcatName as it's source, so the control is bound.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    I agree with Orange and Gasman as to not storing the concatenated value.

    It's much more flexible to construct the concatenation on demand. There are some tricks to make it look cleaner.

    For example you may have a table with the fields- FirstName, MiddleName, LastName, Suffix.

    Using something like -
    FirstName & " " & MiddleName & " " & LastName & " " & Suffix
    - will work but if the person has no middle name you'll have extra spaces between the first and last name.

    To get around the extra spaces you use the fact that a Null plus (+) anything will always be Null.
    "A" & Null = "A"
    "A" + Null = Null

    Note the grouping and uses of the ampersand (a string operator) and the plus sign (a mathematical operator)

    (FirstName + " ") & (MiddleName + " ") & (LastName) & (" " + Suffix)
    The above will always be properly spaced whether the person has a middle name or not. A Null MiddleName plus a space is Null.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    i need to store the concatenation in a table so that it can be used by another form.. I want to only do the concatenation once, instead of everytime (which is many times) that i need to use it.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,998
    So make a control (hidden if you like) that is bound to the field and set that control.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    the concatenation has to be a seperate field in the table ........ So i need to concatenate it when i press the SAVE button, and have the concatenation placed into the table column


    Can i use some sort of EXPRESSION in the table to do this or do i need to do it at the FORM level?

  8. #8
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    i am new to access so im not sure what you are saying.

    i did create a text box with the CONTROL SOURCE BLANK.... and on a CLICK, i call a sub procedure to concatenate the names .
    I want the value of XLONG to be put into my table field named CONCAT_LONG

    Click image for larger version. 

Name:	Capture1.PNG 
Views:	15 
Size:	54.7 KB 
ID:	50736Click image for larger version. 

Name:	Capture2.PNG 
Views:	15 
Size:	30.2 KB 
ID:	50737

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,998
    No need for a variable, just set the control to that concatenated string.
    You could the code in the button click event.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    Quote Originally Posted by jker View Post
    i need to store the concatenation in a table so that it can be used by another form.. I want to only do the concatenation once, instead of everytime (which is many times) that i need to use it.
    Then create a function to return the Concatenated string.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  11. #11
    jker is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Aug 2023
    Posts
    36
    sOLUTION HAS BEEN FOUND:

    I created an ENTER event for a button, as follows:

    Private Sub btnSave_Enter()


    CUST_CONCAT_LONG = CUST_LNAME & ", " & CUST_FNAME & " " & CUST_INITIAL & ", " & CUST_PHONE & ", " & CUST_CITY


    End Sub

    CUST_CONCAT_LONG is a column name in my table . When the SAVE button is pressed, the concatenation happens nd stores results in the database column

  12. #12
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,998
    So many people think they have to save records in Access, when it does it for you?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  13. #13
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,655
    Gotta ask. Why are you using the Enter Event of a command button?

    Code:
    Private Sub btnSave_Enter()
    Wouldn't the click event be more appropriate?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  14. #14
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    I guess none of these answers were appreciated, so now double posted
    https://www.accessforums.net/showthread.php?t=88639
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Move status bar to top of form
    By fat_ankles in forum Forms
    Replies: 6
    Last Post: 12-18-2015, 09:44 PM
  2. Replies: 3
    Last Post: 12-11-2014, 11:26 AM
  3. move a form with a macro
    By orcaa in forum Programming
    Replies: 1
    Last Post: 01-19-2013, 11:31 AM
  4. Replies: 11
    Last Post: 10-08-2012, 07:27 PM
  5. Replies: 1
    Last Post: 08-09-2010, 03:59 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