Hello Arnicot,
Here is a method that I used a few years ago, when I was teaching a
beginning Access course. At the end of the quarter, I would send out a
message to all students, which included a snapshot report of the scores that
I had recorded for the assignments, quizes, tests, etc. This code was used in
an Access 2000 database, but I believe it should work in Access 97 without a
problem.
The report, which was named "rptStudentScores", was based on query that
included a criteria that looked to the record on the open form to grab it's
primary key. The command button, named "cmdSendReportToStudent" was placed on
the same form, which was named "frmStudents". The query's criteria includes
the following for the primary key field:
[Forms]![frmStudents]![PK_StudentID]
In my case, I simply hard-coded the text of the message, since it didn't
need to be customized for each student. I also used EditMessage:=True, so
that I could add any additional text to a particular message if I so desired.
With EditMessage:=False, you will get a security warning if you have
installed all of the Office service packs (at least in Access 2000 and
above--I don't know for sure about Access 97, but I suspect the same is true).
Here is the code that is run when the command button on the form is clicked:
Private Sub cmdSendReportToStudent_Click()
On Error GoTo ProcError
Dim strDocName As String
Dim strReceipient As String
Dim strFirstName As String
Dim strSubject As String
Dim strMessage As String
strDocName = "rptStudentScores"
strReceipient = Me!sfrm1!EMailAddress
strFirstName = Me!FirstName
strSubject = "Recorded Scores"
strMessage = "Hello " & strFirstName & " -" & vbCrLf & vbCrLf & _
"Here is a summary of the scores that I have recorded for you." _
& " I hope you feel you have learned a lot about Access in the last 11
weeks." _
& vbCrLf & vbCrLf & "Tom Wickerath" & vbCrLf & vbCrLf & vbCrLf & _
"PS. If you cannot open the attached file, then you need to install " _
& "the SnapShot viewer utility. It can also be downloaded from
Microsoft at: " _
& vbCrLf & "
http://www.microsoft.com/accessdev/prodinfo/snapshot.htm" _
& vbCrLf & vbCrLf & "Make a note of the folder that you save it to.
After the " _
& "download is complete, use Windows Explorer to open this folder, and
install the " _
& "viewer by double-clicking on the Snapvw.exe file."
DoCmd.SendObject ObjectType:=acReport, ObjectName:=strDocName, _
OutputFormat:=acFormatSNP, To:=strReceipient, _
Subject:=strSubject, MessageText:=strMessage,
EditMessage:=True
ExitProc:
Exit Sub
ProcError:
MsgBox "Error: " & Err.Number & ". " & Err.Description, _
vbCritical, "Error in cmdSendReport procedure..."
Resume ExitProc
End Sub
Tom
_________________________________________
:
Hi!
I built a report which contains orders I'd like to email. I didn't find
the way to select individually the orders. So far, all the report (as a
unique entity) can be attached to an email instead of proceeding order
by order.
Could someone help me ?
Thanks