Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2010
    Location
    GA.
    Posts
    23

    Put data from a table

    I have a table with Addresses " tblAddress " it may only have 2 to 6 or so addresses.
    I want to click a button on my form and pull all of them from that table and concatenate them all in a Long Text field name " txtAllAddress " with " / " in between them.
    Like this:


    " & Address1 & "/ " & Address2 & "/ " & Address3 & " "


    Thanks for any help.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    does the table have side-by-side fields: Address1 , Address2 , Address3?

    if so, make a query and create a new field:

    Addr: Address1 & "/ " & Address2 & "/ " & Address3

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    FogLine,

    Tell us more about your database. I'm sure you have more than 1 table, and that you use this database to support some "business processes". A little more info would help readers.

  4. #4
    Join Date
    Jul 2010
    Location
    GA.
    Posts
    23
    No the Address table would be a list of addresses
    it may be 2 to 10 or so addresses

  5. #5
    Join Date
    Jul 2010
    Location
    GA.
    Posts
    23
    What i am trying to do is .
    I have a truck routing program and the user will enter all of the Pickup and Drop address.
    I need to concatenate them like Address1 & "/ " & Address2 & "/ " & Address3
    I will use this to do a route with Google Maps.
    It works like this:
    https://www.google.com/maps/dir/" & Address1 & "/ " & Address2 & "/ " & Address3 & "

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Each address is in a separate record? Review http://allenbrowne.com/func-concat.html
    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
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    If you are referring to separate fields in the same address I would use commas between each part of the address.
    It will still work in google maps and can then be used as an address line
    It will also work using + sign which google converts it to anyway
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  8. #8
    Join Date
    Jul 2010
    Location
    GA.
    Posts
    23
    I got it working....

    Me.txtAllAddress = SimpleCSV("SELECT FullAddress FROM qryRouteFullAddress", " / ")



    Public Function SimpleCSV(strSQL As String, Optional strDelim As String = ",") As String
    'Returns a comma delimited string of all the records in the SELECT SQL statement


    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim strCSV As String


    Set db = CurrentDb()
    Set rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
    'Concatenate the first (and should be the only one) field from the SQL statement
    With rs
    Do While Not .EOF
    strCSV = strCSV & strDelim & .Fields(0)
    .MoveNext
    Loop
    .Close
    End With
    'Remove the leading delimiter and return the result
    SimpleCSV = Mid$(strCSV, Len(strDelim) + 1)
    Set rs = Nothing
    Set db = Nothing
    End Function

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

Similar Threads

  1. Replies: 9
    Last Post: 08-11-2016, 11:30 AM
  2. Replies: 5
    Last Post: 08-25-2015, 08:39 AM
  3. Replies: 1
    Last Post: 05-31-2015, 09:20 AM
  4. Replies: 5
    Last Post: 09-06-2013, 11:52 AM
  5. Replies: 13
    Last Post: 10-04-2012, 04:15 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