Microsoft Office Tutorials and References
In Depth Information
E-mailing a Selection
' First test if the FilterOn is true to see if the filter has been
applied¶
If Me.FilterOn = True Then¶
' Move the filter to the txtFilter field of the parent form¶
Parent.txtFilter = Me.Filter¶
Else¶
' Empty the txtFilter field of the parent form¶
Parent.txtFilter = ¶
End If¶
Finally, code is added behind the Email Selection button to loop through all
selected rows.
Follow these steps:
1. Ensure that the application is referencing the correct library. To be
backward compatible, choose the older DAO library.
2. To make sure that the application works, open the Tools/References
when in the VBA code window and select a reference to a Microsoft
DAO version x.xx library. The version number is not relevant for our
purposes.
Now for the code:
Private Sub btnEmail_Click()¶
Dim rs As DAO.Recordset ' object to hold the recordset¶
Dim strWhere As String ' variable to hold the needed WHERE clause¶
' Test if a selection has been made, when not¶
' first confirm that all persons need to be mailed.¶
If Len(Me.txtFilter) > 0 Then¶
' Create the WHERE clause for the email processing¶
' by concatenating WHERE with the build filter string¶
strWhere = WHERE & Replace(Me.txtFilter, sfrmName., )¶
Else¶
' Ask for confirmation¶
If MsgBox(, vbYesNo) = vbYes Then¶
' All means no WHERE clause needed¶
strWhere = ¶
Acs
Search JabSto ::




Custom Search