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
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