Results 1 to 5 of 5
  1. #1
    menntu is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2009
    Posts
    1

    Need Code to Concatenate All Records


    Hi, I've a simple request. I have one table (tblAddresses) that has a single field (Email). I'd like a piece of code to grab all the Emails and sling them into a single memo/text box on my main menu (frmMenu). The results are not going to be tied to any individual record, just something I can then copy and paste into a different application. Can someone guide me through this?

    Thank you!

    Destin Richter
    richter@newmexico.com

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You may find this link useful.

  3. #3
    tinytree is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2009
    Posts
    28
    -----access VBA-------
    dim a() as string,dim i as long
    set dbs=currentdb
    set rst=dbs.openrecordset("tblAddresses",dbopentalbe)
    rst.movelast
    redim a(1 to rst.recordcount)
    rst.movefirst
    i=1
    do until rst.eof

    loop

  4. #4
    tinytree is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2009
    Posts
    28
    do until rst.eof
    a(i)=rst(0)
    rst.movenext
    loop
    dbs.close
    set dbs=nothing
    set rst=nothing

  5. #5
    Patrick.Grant01 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    30

    This might be useful .....

    This might help ......

    Public Sub SendEMail(strDestinationMailBox As String, strBodyofMessage As String, _
    strSubjectOfMessage As String, Optional strContact, Optional strCopiesOfMessage As String, Optional strAttachment As String)

    'error trapping routine
    On Error GoTo Err_SendEMail

    'procedure level scope
    Dim mapOutlook As Outlook.Application
    Dim mapNameSpace As NameSpace
    Dim mapFolder As MAPIFolder
    Dim mapMessage As MailItem
    Dim strFirstName As String


    Set mapOutlook = CreateObject("Outlook.Application")
    Set mapNameSpace = mapOutlook.GetNamespace("MAPI")
    mapNameSpace.Logon
    Set mapFolder = mapNameSpace.GetDefaultFolder(olFolderOutbox)
    Set mapMessage = mapOutlook.CreateItem(olMailItem)


    strBodyofMessage = strFirstName + Chr(10) + Chr(13) + strBodyofMessage

    With mapMessage
    'set destination
    .To = strDestinationMailBox
    'set subject
    .Subject = strSubjectOfMessage

    'set the body of the message
    .Body = strBodyofMessage
    'if there are copies then send then
    If strCopiesOfMessage <> "" Then .CC = strCopiesOfMessage

    'and send the message
    ' Add Attachment
    If strAttachment <> "" Then .Attachments.Add strAttachment

    .Save

    End With
    'shut down the message system
    mapNameSpace.Logoff
    'and renulifiy the objects in order
    Set mapMessage = Nothing
    Set mapFolder = Nothing
    Set mapNameSpace = Nothing
    Set mapOutlook = Nothing


    'Debug.Print strSubjectOfMessage & " - OK "
    Exit_SendEMail:

    Exit Sub

    Err_SendEMail:
    Debug.Print strSubjectOfMessage & " - Failed "
    MsgBox "SendEMail: " & Err.Number & " " & Err.Description
    Resume Exit_SendEMail

    End Sub

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

Similar Threads

  1. concatenate string using loop
    By nengster in forum Programming
    Replies: 0
    Last Post: 02-23-2009, 08:05 PM
  2. Code Trouble?
    By briancb2004 in forum Access
    Replies: 0
    Last Post: 10-08-2008, 04:47 PM
  3. Need help with code
    By hoenheim in forum Programming
    Replies: 9
    Last Post: 09-11-2008, 04:19 PM
  4. Need Help Getting to Code
    By Snuffles in forum Programming
    Replies: 8
    Last Post: 04-22-2008, 05:25 PM
  5. Concatenate two fields (text & number) for key field
    By Larry Elfenbein in forum Forms
    Replies: 2
    Last Post: 11-10-2005, 07:45 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