Solved

Get row headers in email for data from ACCESS 2003

Posted on 2008-10-29
3
179 Views
Last Modified: 2013-11-25
I am working on getting a email automation out of our database.  The first part of the body is standard text depending on how many days an account has been opened and then below that in the email are the various rows with customer data the manager has to review (they do NOT want an attachment, they want the data in the e-mail itself)  I have managed to get to the point where the body and rows are in the email, but how do I get the column headers for the rows information?  right now,just the data appears, not the column titles.
Private Sub ActualEmail()

Dim strMessage As String, txtMaxBranch As String, strTo As String

Dim strSubject As String

Dim appOutLook As Outlook.Application, MailOutLook As Outlook.MailItem

Dim strAddress As String, rstEmail As DAO.Recordset

txtMaxBranch = DMax("BR_NMR", "tblAMLUploadedToday")

Set db = CurrentDb

Set rst = db.OpenRecordset("qryEmail")
 

Set appOutLook = CreateObject("Outlook.Application")

Set MailOutLook = appOutLook.CreateItem(olMailItem)

'strAddress = Me.txtEmailAddress

rst.MoveFirst

            strMessage = Me.txtBody & vbCrLf & vbCrLf

            Set appOutLook = CreateObject("Outlook.Application")

            Set MailOutLook = appOutLook.CreateItem(olMailItem)

            With MailOutLook

                .To = txtMaxBranch

                .Subject = Me.txtSubject

                .Body = strMessage

Debug.Print strMessage

' *****************

Do Until rst.EOF

If strMessage = "" Then

strMessage = rst("BR_NMR") & "," & rst("OFCR_CD") & "," & rst("PLAN_NBR") & "," & rst("DAYS_OPEN_CNT") & "," & rst("APPL_TYP_CD") & "," & rst("ACCT_NBR") & vbCrLf & _

    "," & rst("REL_CD") & "," & rst("NM_LINE_1") & "," & rst("NM_LINE_2") & "," & rst("NM_LINE_3") & "," & rst("TAX_ID_NBR") & "," & rst("CIF_NBR") & vbCrLf & _

    "," & rst("NAME_FLG") & "," & rst("TAX_ID_FLG") & "," & rst("DOB_CIF_FLG") & "," & rst("DOB_ACCT_FLG") & "," & rst("GOVMT_ID_FLG") & "," & rst("ADDR_FLG") & vbCrLf & _

    "," & rst("PO_BOX_FLG") & "," & rst("PHONE_FLG") & "," & rst("OFCF_CD_FLG") & "," & rst("OPEN_DT") & "," & rst("OWNR_CD") & "," & rst("MOTHER_NM_FLG") & vbCrLf & _

    "," & rst("OCCUPATION_FLG") & "," & rst("EMPLR_FLG") & vbCrLf

Else

strMessage = strMessage & rst("BR_NMR") & "," & rst("OFCR_CD") & "," & rst("PLAN_NBR") & "," & rst("DAYS_OPEN_CNT") & "," & rst("APPL_TYP_CD") & "," & rst("ACCT_NBR") & vbCrLf & _

    "," & rst("REL_CD") & "," & rst("NM_LINE_1") & "," & rst("NM_LINE_2") & "," & rst("NM_LINE_3") & "," & rst("TAX_ID_NBR") & "," & rst("CIF_NBR") & vbCrLf & _

    "," & rst("NAME_FLG") & "," & rst("TAX_ID_FLG") & "," & rst("DOB_CIF_FLG") & "," & rst("DOB_ACCT_FLG") & "," & rst("GOVMT_ID_FLG") & "," & rst("ADDR_FLG") & vbCrLf & _

    "," & rst("PO_BOX_FLG") & "," & rst("PHONE_FLG") & "," & rst("OFCF_CD_FLG") & "," & rst("OPEN_DT") & "," & rst("OWNR_CD") & "," & rst("MOTHER_NM_FLG") & vbCrLf & _

    "," & rst("OCCUPATION_FLG") & "," & rst("EMPLR_FLG") & vbCrLf & vbCrLf

End If

Debug.Print strMessage

rst.MoveNext

Loop
 

DoCmd.SendObject , , , strTo, , , strSubject, strMessage, 1  'Move outside the loop
 

'

''***********************

                 .Send

               End With

'skip_email:

'        rst.MoveNext

'    Loop

'    rst.Close

'    Set rst = Nothing
 

End Sub

Open in new window

0
Comment
Question by:ssmith94015
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 22833997
You can get the actual name of the field like this:

rst("BR_NMR").Name

0
 

Author Comment

by:ssmith94015
ID: 22834128
would this be the first line in the message part that holds the row data?
0
 

Author Closing Comment

by:ssmith94015
ID: 31511272
I figured out the placement, thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now