Solved

Get row headers in email for data from ACCESS 2003

Posted on 2008-10-29
3
180 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

813 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

11 Experts available now in Live!

Get 1:1 Help Now