Hi,
I'm new to VBA because I inherited an access db from a former colleague that contains a module written in VBA that I've been asked to modify. This code extracts 'TABLE1' from the current access db and emails it to select individuals. what do I change/add in the code below to be able to send multiple tables in the same email.
So I need it to send TABLE1 and TABLE2 and TABLE3, etc. in the same one email, of course separated by line breaks.
I would greatly appreciate it someone could help me out.
I'm new to VBA because I inherited an access db from a former colleague that contains a module written in VBA that I've been asked to modify. This code extracts 'TABLE1' from the current access db and emails it to select individuals. what do I change/add in the code below to be able to send multiple tables in the same email.
So I need it to send TABLE1 and TABLE2 and TABLE3, etc. in the same one email, of course separated by line breaks.
I would greatly appreciate it someone could help me out.
Code:
Dim Conn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim doc As Word.Document
Dim strSQL As String
Dim varRst As Variant
Dim f As Variant
Dim strHead As String
Dim Maildb As Object
Dim MailDoc As Object
Dim Body As Object
Dim Session As Object
Dim richtext As Object
Set Conn = New ADODB.Connection
Set rst = New ADODB.Recordset
Conn.Provider = "Microsoft.Ace.OLEDB.12.0;" & "Data Source=" & _
CurrentProject.Path & _
"\Database51.accdb"
strSQL = "SELECT *FROM TABLE1"
Conn.Open
rst.Open strSQL, Conn, adOpenUnspecified, adLockUnspecified, adCmdText
If Not rst.EOF Then
varRst = rst.GetString(, , vbTab, vbCrLf)
For Each f In rst.Fields
strHead = strHead & f.Name & vbTab
Next
End If