Mike,
The snap shot file format is available only for reports,
so you have two choices.
1) You can send your query using another format, like
Excel.
2) You can create a report that is based on your query
and send the report instead of the query and then you can
use the snap shot file format.
Here's a simple example of a function that will send a
query or report as an email attachment:
Public Function fnSendQueryData(strEmail As String, strObj
As String, _
strDistrict As String)
On Error GoTo Err_fnSendQueryData
Dim strSubject As String
Dim strMsgTxt As String
strSubject = "Data Export For " & strDistrict
strMsgTxt = "Your message text goes here."
'To allow the user to edit the email, change
the "False" to "True" at the end
'of the below DoCmd statements.
'To send query: (snapshot format is not available for
queries)
DoCmd.SendObject acSendQuery, strObj, acFormatXLS,
strEmail, , , strSubject, strMsgTxt, False
'To send report:
'DoCmd.SendObject acSendReport, strObj, acFormatSNP,
strEmail, , , strSubject, strMsgTxt, False
Exit_fnSendQueryData:
Exit Function
Err_fnSendQueryData:
If Err.Number <> 2501 Then
MsgBox "Error #: " & vbTab & vbTab & Err.Number &
vbCrLf _
& "Description: " & vbTab & Err.Description
End If
Resume Exit_fnSendQueryData
End Function
You can execute the function using a line like this:
fnSendQueryData "(e-mail address removed)", "YourQueryOrReport
", "District 21"
You will also need to decide whether/how to dynamically
select the records to include in your query or report.
One method is to select parameters in a form and have your
query reference the controls on the form as filter
parameters. Likewise, the destination email address could
also be displayed in the form and passed to the function
call by referencing the text box containing the email
address. You could call the function from the click event
of a button on this form.