Send Records from Form, Method or Data Error not Found"

B

bymarce

I have a form called WorkAssignments. I'm trying to email selected records
from this form with a command button. From reading posts I saw that I needed
to make sure the form is filtered before sending it. I have two filter boxes
and a button to apply the filter. The code for filtering is based on Allen
Browne's site.

Private Sub cmdFilter_Click()

Dim strWhere As String
Dim lngLen As Long
Const conJetDate = "\#mm\/dd\/yyyy\#"

If Not IsNull(Me.fAssignedTo) Then
strWhere = strWhere & "([TestAssignedTo] = """ & Me.fAssignedTo &
""") AND "
End If

If Not IsNull(Me.fAssignedOn) Then
strWhere = strWhere & "([TestAssignedOn] = """ & Me.fAssignedOn &
""") AND "
End If

lngLen = Len(strWhere) - 5
If lngLen <= 0 Then
MsgBox "No Criteria", vbInformation, "Nothing to do."
Else
strWhere = Left$(strWhere, lngLen)

Me.Filter = strWhere
Me.FilterOn = True
End If

On Error GoTo Err_Filter_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 2, , acMenuVer70

Exit_Filter_Click:
Exit Sub

Err_Filter_Click:
MsgBox Err.Description
Resume Exit_Filter_Click
End Sub

Private Sub Email_Work_Click()

Dim SendTo As String, MySubject As String, MyMessage As String
SendTo = Me.Email
MySubject = Me.MLO
MyMessage = "Please complete the following tests for " & Me.MLO & "."
DoCmd.SendObject acSendForm, Me.WorkAssignments, , SendTo, , , MySubject,
MyMessage, False

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top