Results 1 to 15 of 15
  1. #1
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370

    Question Concatenation

    Hi guys,

    I'm trying to have txtBox1 display: ([first 20 characters of COMBOBOX1], [Name], [Date])

    How do i pull the first 20 characters of the combobox value, and also what is the appropriate syntax for actually concatenating it?



    Thank you all!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Left([combobox1,20) & ", " & [Name] & ", " & [Date]

    More about string functions: http://msdn.microsoft.com/en-us/library/dd789093.aspx

    Name and Date are reserved words. Should not use reserved words as names.
    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.

  3. #3
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Thanks June7, I was using those field names as examples, I know that

  4. #4
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Getting #Name? error :\

    Where does the bracket go for the combobox in the SQL you gave?

  5. #5
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Oh I know why, My data column is in Column 2 in the comboBox, how would I add that to the SQL?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is the actual value of the combobox? Is it a multi-column combobox? Which column do you want the 20 characters from?

    EDIT: Didn't see your last posts

    Reference columns by index. Index begins with zero

    [combobox1].[Column](1)

    Rats! Access query object won't recognize the Column reference.

    Exactly what are you trying to do?
    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.

  7. #7
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Well, I have a form with the combobox and other two text boxes, My boss would like a simple way to have them concatenated for a copy and paste.

    Only using it for copy and paste, I wont be calling it again, So is there anyway in VBA to make a temp var and add on each value from the cbobox and then add the two text boxes, and then for the actual new textbox, just set it equal to the temp var?

    I would have no idea how to do that, but its just some food for thought.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Why did you ask about SQL?

    Copy/paste from where to where?
    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.

  9. #9
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Well my boss wants to copy the concatenation and then use it either in an email or something, I'm not exactly sure, I just know he wants those 3 things combined in one text box to be able to copy them all at once, so that he can then paste it wherever he needs to. I'm just trying to follow directions is all

  10. #10
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    I think this :
    [combobox1].[Column](1)

    should be this:
    [combobox1].Column(1)

    Remove square brackets off Column, so you would have something like this:

    Left([combobox1].column(1), 20) & ", " & [Name] & ", " & [Date]

    John
    Last edited by John_G; 08-01-2014 at 01:25 PM. Reason: add information

  11. #11
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    The concatenation expression referencing Column index should work in a textbox ControlSource. Access will throw in the [] around Column even if you don't type them. VBA won't. I know, weird!
    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.

  12. #12
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    This is what I'm using and I'm getting the #Name?

    [Left([cboPlanName].[Collumn(1),20)]]
    Ive also tried
    [Left([cboPlanName].[Collumn](1),20)]
    Ive also tried
    [Left([cboPlanName].Collumn(1),20)]

    None of those have worked :\

  13. #13
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    This is the right one: [Left([cboPlanName].Collumn(1),20)]

    but Column only has 1 "l" in it, and don't enclose the whole thing in square brackets:

    me!textboxname = Left([cboPlanName].Column(1),20) & .... other data

    John

  14. #14
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try:
    Left([cboPlanName].[Column](1),20)
    precede with = if you are using this as the Control Source of a text box
    =
    Left([cboPlanName].[Column](1),20)

    EDIT
    Sorry John. My typing is clearly a bit slow.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  15. #15
    cbende2's Avatar
    cbende2 is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jun 2014
    Location
    Louisiana
    Posts
    370
    Thank you guys, I got it working now!

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

Similar Threads

  1. Concatenation
    By lantoni in forum Access
    Replies: 31
    Last Post: 03-06-2014, 07:29 AM
  2. concatenation issue
    By SuicidalDriver in forum Queries
    Replies: 11
    Last Post: 07-31-2013, 04:42 AM
  3. Concatenation
    By Rhubie in forum Access
    Replies: 3
    Last Post: 08-30-2012, 05:09 PM
  4. Query and Concatenation
    By Try2Live4God in forum Programming
    Replies: 2
    Last Post: 05-25-2010, 03:45 PM
  5. Concatenation Urgent Help
    By Shoaib in forum Queries
    Replies: 0
    Last Post: 04-23-2009, 11:02 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