Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2007

Tip: Looking for answers? Try searching our database.

SQL statements

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wendy - 08 Mar 2007 12:58 GMT
Hi

Is there a reference on the web which would show me how to run sql
statements from within my vb module.  Or could someone show me how to get
started.  I want to use Dev Ashish's Send Email Outlook module but take the
attachment names from my data table and cannot get it to work.

Thanks

Wendy
Douglas J. Steele - 08 Mar 2007 14:00 GMT
Assuming you're talking about the code in
http://www.mvps.org/access/modules/mdl0019.htm, you could either use the
DLookup function to get the attachment name, as in replacing

 MAPIAddAttachment stFile:="C:\config.sys"

with

Dim varFile As Variant

 varFile = DLookup("[FileName]", "[MyTable]", "User =
'dash10@hotmail.com'")
 If IsNull(varFile) = False Then
   MAPIAddAttachment stFile:=varFile
 End If

or you could open a recordset that returns the details of what you want to
send to whom, and loop through that recordset. The basic approach to using a
recordset is:

Dim rsCurr As DAO.Recordset
Dim strSQL As String
Dim clMAPI As clsMAPI

 Set clMAPI = New clsMAPIEmail

 strSQL = "SELECT EMailAddress, FileName FROM MyTable"
 Set rsCurr = CurrentDb.OpenRecordset(strSQL)
 Do Until rsCurr.EOF
   With clMAPI
       .MAPILogon
       .MAPIAddMessage
       .MAPISetMessageBody = "Test Message"
       .MAPISetMessageSubject = "Some Test"
       .MAPIAddRecipient stPerson:=rsCurr!EmailAddress, _
                                   intAddressType:=1
       .MAPIAddAttachment stFile:=rsCurr!FileName
       .MAPIUpdateMessage
       .MAPISendMessage boolSaveCopy:=False
       .MAPILogoff
   End With
   rsCurr.MoveNext
 Loop

 rsCurr.Close
 Set rsCurr = Nothing

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> Hi
>
[quoted text clipped - 7 lines]
>
> Wendy
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.