Hi...Please help....this code works but with one problem the feilds [Item] and [EmailAddress] both require an exclamation mark ! in front of them for it to work, this makes the results of the feilds display the first record from the table where as the feilds [Job Number] and [Job Name] don't require the !. so i get the right results from them.
When i take the ! mark away from the feilds i get run time error 2465 "feild can't be found"...
Code:
Private Sub cmdJointApp_Click()
On Error GoTo Macro6_Err
Dim oOApp As Outlook.Application
Dim oOMail As Outlook.MailItem
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSubject As String
Dim strBody As String
Dim strEmail As String
Dim strJobNumber As String
Dim sql As String
With CodeContextObject
strJobNumber = Me.Job_Number
End With
Call CombimneValuesJA
Set oOApp = CreateObject("Outlook.Application")
Set oOMail = oOApp.CreateItem(olMailItem)
Set db = CurrentDb
Set rs = db.OpenRecordset("TempItems", dbOpenDynaset)
With rs
rs.FindFirst "[Job Number] = ""strJobNumber"""
If Not rs.NoMatch Then
Exit Sub
End If
sql = ![Items]
strSubject = ([JobNumber] & " " & [Job Name] & " items ready for Joint Approval")
strBody = ("The Factory requires joint approval on the following items, " & Chr(13) & Chr(10) & sql)
strEmail = ![EmailAddress]
End With
With oOMail
.To = strEmail
.subject = strSubject
.Body = strBody
.Display
End With
Macro6_Err:
MsgBox Error$
Me.Undo
Exit Sub
End Sub