New to VBA (1 Viewer)

bluke829

New member
Local time
Today, 12:22
Joined
Sep 2, 2015
Messages
5
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.
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
 

JHB

Have been here a while
Local time
Today, 19:22
Joined
Jun 17, 2012
Messages
7,732
It can't be the whole code!
 

Trevor G

Registered User.
Local time
Today, 18:22
Joined
Oct 1, 2009
Messages
2,341
Welcome to the forum, can you show all of the code so someone can help.
 

Users who are viewing this thread

Top Bottom