Ade F
Avid Listener
- Local time
- Today, 12:39
- Joined
- Jun 12, 2003
- Messages
- 97
I have returned to this good ole faithful forum in the hope that somone could assist in my technical stumbling block. It has been years since my last visit but upon returning I still see the pro names with massive reply counts. My hat's off to those who are doing this as a profession and still have time for people such as myself.
Having cobbled together the code below from other sources I have managed to get an email on click output to outlook.
The DB has two tables
tblMain_Bird
tblBird_Detail
In the bird detail I'm planning on recording various types of birds and numbers
tblMain_Bird - Main tbl
tblBird_Detail
BirdID - Autonumber
BirdDescription - Text
BirdNumber - Number
The recorded output would end up ebing
Bird Description - Quantity
My question is this, the information below prints into the tblMain_Bird information great but the sub form that records bird description and quantity has continuous forms. How would I go about printing into the email body the tclbird recorded detail?. Is there a way of looping through the sub forma and printing it out to the stText? (or something similar via another var).
This is a little confusing and any help would be greatly appreciated. Essentially this will allow me to record the birds via the main / sub form and easily email the data to my recipient on a weekly basis. I'm sure this example could be used for a multitude of applications so I'm hoping this may help others should a suitable solution be found. If an example file exists in a better format then please do say I'm not proud to put this to one side and take advice from a new avenue.
Regards
Ade
---------------------------------------------
Private Sub cmdMailTicket_Click()
On Error GoTo Err_cmdMailTicket_Click
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stTicketID As String '-- The ticket ID from form
Dim stWho As String '-- Reference to tblUsers
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.cboAssignee
stWhere = "tblMain_Bird.strUserID = " & "'" & stWho & "'"
'-- Looks up email address from TblUsers
varTo = DLookup("[strEMail]", "tblMain_Bird", stWhere)
stSubject = "Bird Survey"
stTicketID = "123456"
RecDate = Me.txtDateReceived
'-- Helpdesk employee who assigns ticket
'strHelpDesk = Me.cboReceivedBy.Column(1)
stText = "Here are the bird findings for this month." & Chr$(13) & Chr$(13) & _
"The total number of birds spotted this month is " & stTicketID & Chr$(13) & Chr$(13) & _
"Best Regards."
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Exit Sub
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
Exit_cmdMailTicket_Click:
Exit Sub
Err_cmdMailTicket_Click:
MsgBox Err.Description
Resume Exit_cmdMailTicket_Click
End Sub
Having cobbled together the code below from other sources I have managed to get an email on click output to outlook.
The DB has two tables
tblMain_Bird
tblBird_Detail
In the bird detail I'm planning on recording various types of birds and numbers
tblMain_Bird - Main tbl
tblBird_Detail
BirdID - Autonumber
BirdDescription - Text
BirdNumber - Number
The recorded output would end up ebing
Bird Description - Quantity
My question is this, the information below prints into the tblMain_Bird information great but the sub form that records bird description and quantity has continuous forms. How would I go about printing into the email body the tclbird recorded detail?. Is there a way of looping through the sub forma and printing it out to the stText? (or something similar via another var).
This is a little confusing and any help would be greatly appreciated. Essentially this will allow me to record the birds via the main / sub form and easily email the data to my recipient on a weekly basis. I'm sure this example could be used for a multitude of applications so I'm hoping this may help others should a suitable solution be found. If an example file exists in a better format then please do say I'm not proud to put this to one side and take advice from a new avenue.
Regards
Ade
---------------------------------------------
Private Sub cmdMailTicket_Click()
On Error GoTo Err_cmdMailTicket_Click
Dim stWhere As String '-- Criteria for DLookup
Dim varTo As Variant '-- Address for SendObject
Dim stText As String '-- E-mail text
Dim RecDate As Variant '-- Rec date for e-mail text
Dim stSubject As String '-- Subject line of e-mail
Dim stTicketID As String '-- The ticket ID from form
Dim stWho As String '-- Reference to tblUsers
Dim strSQL As String '-- Create SQL update statement
Dim errLoop As Error
'-- Combo of names to assign ticket to
stWho = Me.cboAssignee
stWhere = "tblMain_Bird.strUserID = " & "'" & stWho & "'"
'-- Looks up email address from TblUsers
varTo = DLookup("[strEMail]", "tblMain_Bird", stWhere)
stSubject = "Bird Survey"
stTicketID = "123456"
RecDate = Me.txtDateReceived
'-- Helpdesk employee who assigns ticket
'strHelpDesk = Me.cboReceivedBy.Column(1)
stText = "Here are the bird findings for this month." & Chr$(13) & Chr$(13) & _
"The total number of birds spotted this month is " & stTicketID & Chr$(13) & Chr$(13) & _
"Best Regards."
'Write the e-mail content for sending to assignee
DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
Exit Sub
Err_Execute:
' Notify user of any errors that result from
' executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & _
errLoop.Description
Next errLoop
End If
Resume Next
Exit_cmdMailTicket_Click:
Exit Sub
Err_cmdMailTicket_Click:
MsgBox Err.Description
Resume Exit_cmdMailTicket_Click
End Sub