Do you mean you don't want them to alter the data in Access, or in the email?
If the latter, and you are attaching it as an Excel workbook, then you could protect that against modification with a password, etc.
I believe he means the user sending the email cannot alter the data prior to it being sent?
If so, then you can loop through the tables and create a Zip file of all the tables, then attach that to the email. The code below has a couple of function:
ExportTables will export all the tables in your database and then create a Zip file and add all of them to the Zip.
EmailTables will email that zip file. You'd want to change the To address and the attachment path to ones suited to your situation.
The functions could certainly be tidied up, and you probably want to not hardcode the filepaths and such.
Dim dbs As DAO.Database
Dim tdf As DAO.TableDef
Dim shell As Object
Dim ZipFile As Variant
Set shell = CreateObject("Shell.Application")
ZipFile = "F:\Documents\TableDump\Tables.zip"
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 4) <> "MSYS" Then
'/ output the table to a CSV file:
DoCmd.TransferText acExportDelim, , tdf.Name, "F:\Documents\TableDump\" & tdf.Name & ".csv", True
shell.namespace(ZipFile).copyhere ("F:\Documents\TableDump\" & tdf.Name & ".csv")
Do Until shell.namespace(ZipFile).items.Count >= 1
Set shell = Nothing
Set tdf = Nothing
Set dbs = Nothing
Private Sub InitializeZipFile( _
ZipFile As String _
Dim intFile As Integer
If Len(Dir(ZipFile)) > 0 Then
intFile = FreeFile
Open ZipFile For Output As #intFile
Print #intFile, Chr$(80) & Chr$(75) & _
Chr$(5) & Chr$(6) & String(18, 0)
Function EmailTables() As Boolean
Dim objOL As Object
Set objOL = CreateObject("Outlook.Application")
Dim olMail As Object
Set olMail = objOL.createitem(0)
.to = "email@example.com"
.subject = "Email Test"
Set olMail = Nothing
Set objOL = Nothing
IT issues often require a personalized solution. With Ask the Experts™, submit your questions to our certified professionals and receive unlimited, customized solutions that work for you.
Take hold of your future.