I use an Access database to collect data from a linked text file and other manual check boxes.
This information is displayed on a form and sub form.
I send this information out on a daily basis so have come up with an event proceedure that forms an outlook mail message. I've got the fields on the form to display correctly in the email, but the sub form is in datasheet view, getting it's data from a table in the same database.
I want the query information to display in the daily email message but am having trouble doing this through VBA code. I also don't want the query as an attachment, I want the actual query to be displayed in the mail message, gridlines and all. Anybody have suggestions?
The name of the query I want to display in the mail message is, "tundra_jobs_query"
Below is the current code that does everything but display the query results:
Private Sub Command83_Click()
'declare variables
Dim strBad As String
Dim strGood As String
Dim strGetTbl As String
'what are the variable values
strBad = "FAILED"
strGood = "OK"
strGetTbl = "SELECT * FROM tundra_jobs_query"
'create new outlook message
Set appoutlook = CreateObject("outlook.application")
Set mailoutlook = appoutlook.CreateItem(olMailItem)
With mailoutlook
'new message parameters
.To = "mail@someone.com"
.cc = "mail@someone.com"
.Subject = "Daily Production Site Report for " & Now()
'these are the checkboxes
.Body = "Data Migration ... " & IIf(Me.[Check_usr_apps_data] = True, strGood, strBad) & vbCr & _
"Search .............. " & IIf(Me.[Site_Search] = True, strGood, strBad) & vbCr & _
"Quick Order ....... " & IIf(Me.[Site_Quick_Order] = True, strGood, strBad) & vbCr & _
"Reports ............. " & IIf(Me.[Site_Report] = True, strGood, strBad) & vbCr & _
"LinkSupport ....... " & IIf(Me.[Suport_Pages] = True, strGood, strBad) & vbCr & _
"Place Order ....... " & IIf(Me.[Site_Place_Order] = True, strGood, strBad) & vbCr & _
"Email ................ " & IIf(Me.[Site_Rec_Order_Email] = True, strGood, strBad) & vbCr & _
"LNKPAS001 ...... " & IIf(Me.[LNKPAS001] = True, strGood, strBad) & vbCr & _
"LNKPAS002 ...... " & IIf(Me.[LNKPAS002] = True, strGood, strBad) & vbCr & _
"LNKPAS003 ...... " & IIf(Me.[LNKPAS003] = True, strGood, strBad) & vbCr & _
.Display
End With
End Sub
The image below is what I would like the mail message to look like. Currently I have to copy and paste the query results into the message.
Any help would be appreciated!
This information is displayed on a form and sub form.
I send this information out on a daily basis so have come up with an event proceedure that forms an outlook mail message. I've got the fields on the form to display correctly in the email, but the sub form is in datasheet view, getting it's data from a table in the same database.
I want the query information to display in the daily email message but am having trouble doing this through VBA code. I also don't want the query as an attachment, I want the actual query to be displayed in the mail message, gridlines and all. Anybody have suggestions?
The name of the query I want to display in the mail message is, "tundra_jobs_query"
Below is the current code that does everything but display the query results:
Private Sub Command83_Click()
'declare variables
Dim strBad As String
Dim strGood As String
Dim strGetTbl As String
'what are the variable values
strBad = "FAILED"
strGood = "OK"
strGetTbl = "SELECT * FROM tundra_jobs_query"
'create new outlook message
Set appoutlook = CreateObject("outlook.application")
Set mailoutlook = appoutlook.CreateItem(olMailItem)
With mailoutlook
'new message parameters
.To = "mail@someone.com"
.cc = "mail@someone.com"
.Subject = "Daily Production Site Report for " & Now()
'these are the checkboxes
.Body = "Data Migration ... " & IIf(Me.[Check_usr_apps_data] = True, strGood, strBad) & vbCr & _
"Search .............. " & IIf(Me.[Site_Search] = True, strGood, strBad) & vbCr & _
"Quick Order ....... " & IIf(Me.[Site_Quick_Order] = True, strGood, strBad) & vbCr & _
"Reports ............. " & IIf(Me.[Site_Report] = True, strGood, strBad) & vbCr & _
"LinkSupport ....... " & IIf(Me.[Suport_Pages] = True, strGood, strBad) & vbCr & _
"Place Order ....... " & IIf(Me.[Site_Place_Order] = True, strGood, strBad) & vbCr & _
"Email ................ " & IIf(Me.[Site_Rec_Order_Email] = True, strGood, strBad) & vbCr & _
"LNKPAS001 ...... " & IIf(Me.[LNKPAS001] = True, strGood, strBad) & vbCr & _
"LNKPAS002 ...... " & IIf(Me.[LNKPAS002] = True, strGood, strBad) & vbCr & _
"LNKPAS003 ...... " & IIf(Me.[LNKPAS003] = True, strGood, strBad) & vbCr & _
.Display
End With
End Sub
The image below is what I would like the mail message to look like. Currently I have to copy and paste the query results into the message.
Any help would be appreciated!