Visual Basic problem with Microsoft Access

Discussion in 'Software' started by ldodson911, Dec 29, 2009.

  1. ldodson911

    ldodson911 Private E-2

    Hello -
    I created a form in Microsoft Access to track frequent problems that are sent to another recipient via email to resolve. So basically, the user enters information into the form, then clicks a command button in the form to create the email to be sent. The purpose is to eliminate duplicate typing for the end user.

    The code works fine from my client machines at home, but does not work on the client machines at the office where it will be used. The only difference that I can think of is that the email client (Microsoft Outlook 2003) that is used at the office location uses an exchange server, while my client machines at home do not use an exchange server.

    When the command button is clicked, after a long delay, Access returns the error "Microsoft Office Outlook can't send email message" or (something close to that, I'm recalling that from memory)...anyway, it does not create the email or send it. The code is set up to present the email to the user first in draft form, then the user manually clicks send in Outlook. Once the email is sent, the form updates checking a box that it has been sent and disables the command button. All of this works fine from the home machines, but not from the office machines.

    I'm googled my brains off trying different routes, but have not found anything that works yet. I'm a VB newbie..just barely hatched, so any help would be appreciated.

    Code:
    Private Sub chkTicketAssigned_AfterUpdate()
    
    'Enable/disable Send Ticket command button
    'if Ticket assigned checkbox is checked/unchecked
    
        If Me.chkTicketAssigned = -1 Then
            Me.cmdMailTicket.Enabled = False
        Else
            Me.cmdMailTicket.Enabled = True
        End If
    End Sub
    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 Variant        '-- 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 = "tblUsers.strUserID = " & "'" & stWho & "'"
        '-- Looks up email address from TblUsers
        varTo = DLookup("[strEMail]", "tblUsers", stWhere)
    
        stSubject = "Service Request\Application\ETS-GIS\CAD Update"
    
        stTicketID = Format(Me.txtTicketID, "00000")
        
         stText = "Area: " & stArea & Chr$(13) & _
                Chr$(13) & "KeyMap: " & stKeyMap & Chr$(13) & _
                Chr$(13) & "Type of Request: " & stCategory & Chr$(13) & _
                Chr$(13) & "Comments: " & stComments & Chr$(13) & _
                Chr$(13) & "HCSO Reference # (HCSO Use Only): " & stTicketID & Chr$(13) & _
                "This is an automated message."
        
        'Write the e-mail content for sending to assignee
        DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stText, -1
    
        'Set the update statement to disable command button
        'once e-mail is sent
        strSQL = "UPDATE tblGISSubmissions SET tblGISSubmissions.ysnTicketAssigned = -1 " & _
                 "Where tblGISSubmissions.stTicketID = " & Me.txtTicketID & ";"
    
    
        On Error GoTo Err_Execute
        CurrentDb.Execute strSQL, dbFailOnError
        On Error GoTo 0
    
        'Requery checkbox to show checked
        'after update statement has ran
        'and disable send mail command button
        Me.chkTicketAssigned.Requery
        Me.chkTicketAssigned.SetFocus
        Me.cmdMailTicket.Enabled = False
    
        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
    
    
     
  2. Kodo

    Kodo SNATCHSQUATCH


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds