Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Trying to send a single record...

    Hello,

    I am trying to send a record via email. This code worked when I tried the first record on the form (it's a Continuous Form) but when I select the 2nd record, it updates all of the fields then does not send. Does anyone know what the issue is here?

    Code:
    Private Sub Combo32_AfterUpdate()
    
    On Error GoTo combo32_err_handling
    
    
    If Me.Text44 = "Please Enter A Due Date!" Then
    MsgBox "Please Enter A Due Date!"
    Me.Combo32 = ""
    Else
    Me.AssignedDate = Date
    Me.AssignEmail = DLookup("Email", "qry_Email", "[EmployeeName]=[Forms]![frm_WorkOrdersUnassigned]![Combo32]")
    Me.AssignedBy = Environ("username")
    Me.AssignedByName = DLookup("EmployeeName", "qry_EmployeeTable", "[Q Number]=[Forms]![frm_WorkOrdersUnassigned]![AssignedBy]")
    Me.Refresh
    Me.Requery
    End If
    
    
    Dim stdocname As String
    Dim stEmail As String
    Dim stSubject As String
    Dim stbody As String
    
    stdocname = "frm_WorkOrdersUnassigned"
    stEmail = Me.RequestedEmail & ";" & Me.AssignEmail
    stSubject = "Updated Work Order #" & Me!Text1
    stbody = ("Work Order #" & Me!Text1 & " has been assigned to " & Me!Combo32 & " by " & Me!AssignedByName & vbCrLf & _
    vbCrLf & _
    "Here are the details of your Work Order:" & vbCrLf & _
    "Service Type:  " & Me!Text8 & vbCrLf & _
    "Problem:  " & Me!Text15 & vbCrLf & _
    vbCrLf & _
    "Description:  " & Me!Text16 & vbCrLf & _
    vbCrLf & _
    "This work order is due to be completed by " & Me.Text44)
    
    DoCmd****nCommand acCmdSelectRecord
    
    If Me.Combo32 <> "" Then
        If Me.AssignEmail <> "" Then
            DoCmd.SendObject acSendNoObject, , , stEmail, , , stSubject, stbody, , False
            Me.Check17 = True
            Me.Requery
            Me.Refresh
        Else
            MsgBox "The person you assigned this to does not have email.  Please inform them about this work order."
            DoCmd.SendObject acSendNoObject, , , stEmail, , , stSubject, stbody, , False
            Me.Check17 = True
            Me.Requery
            Me.Refresh
            End If
    Else
    Exit Sub
    End If
    
    combo32_err_handling_resume:
    Exit Sub
    
    combo32_err_handling:
    MsgBox (Err.Description)
    Me.AssignedDate = ""
    Me.AssignEmail = ""
    Me.AssignedBy = ""
    Me.AssignedByName = ""
    Me.Check17 = False
    Me.Combo32 = ""
    Resume combo32_err_handling_resume
    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    If you want to only send one row, you have to filter the form prior to sending it.
    Have a nice day!

  3. #3
    Join Date
    Oct 2009
    Posts
    204
    Yes I think I found a workaround. I'll use an unbound form with a combo box filtering the records I want, and dlookups to all the fields, with update queries for the fields I want to update....Should work I think.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •