Results 1 to 3 of 3
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839

    Runtime 438 error

    I've used a variation with this code with success. it had an additional function of outputting a file,attaching it, then killing the file in the temp location after sending it.



    This one uses no files, but gets the 438 error. what am I missing here?

    Code:
    Private Sub Main_ID_AfterUpdate()
        Me.Filter = "RFI_Numbers=" & Me.Main_ID
        Me.FilterOn = True
     End Sub
    
    Private Sub Command50_Click()
     On Error GoTo ErrorMsgs
     Dim objOutlook As Outlook.Application
     Dim objOutlookMsg As Outlook.MailItem
     Dim objOutlookRecip As Outlook.Recipient
     Dim strBody, strAddresses, strSubject As String
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
    With objOutlookMsg
        .Subject = "RFI for " & ![System Name] & " - " & ![Nomenclature] & " - " & Format(Date, "dd mmm yy")
        .Body = "The below information is provided for this Request For Information" & vbCrLf & vbCrLf & "In Compliance" & Chr(9) & !Compliance _
                & Chr(9) & Chr(9) & "Field:" & Chr(9) & ![Field Name] & vbCrLf & vbCrLf & "System Name:" & Chr(9) & ![System Name] _
                & vbCrLf & "Nomenclature:" & Chr(9) & ![Nomenclature] & vbCrLf & "Version:" & Chr(9) & !Version & vbCrLf & vbCrLf _
                & "Accreditation Type:" & Chr(9) & Chr(9) & !Type_ACC & Chr(9) & !Accred & vbCrLf & "Accreditation Number:" & Chr(9) & Chr(9) & ![ACC_#] _
                & vbCrLf & "Expiration Date:" & Chr(9) & Chr(9) & Format(!Expires, "dd mmmm yyyy") & vbCrLf & vbCrLf & vbCrLf & "Thank You" & vbCrLf _
                & vbCrLf & "V/R" & vbCrLf & "Name" & vbCrLf & vbCrLf & "Comamnd" & vbCrLf _
                & "Division" & vbCrLf & "BLDG" & vbCrLf & "City" & vbCrLf & "Tel number" _
                & vbCrLf & "Email Address"
        DoCmd.Close acForm, "Main Input"
       .Display
     End With
     Set objOutlookMsg = Nothing
     Set objOutlook = Nothing
     Set objOutlookAttach = Nothing
      Exit Sub
    ErrorMsgs:
     If Err.Number = "287" Then
     MsgBox "You clicked No to the Outlook security warning. " & _
     "Rerun the procedure and click Yes to access e-mail " & _
     "addresses to send your message."
     Else
     MsgBox Err.Number & " " & Err.Description
    End If
    End Sub

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    What is the exact message of the error? What line triggers the error? Have you step debugged?

    I expect the references to form fields are causing error. You have the email as the object of WITH but then the code concatenates fields without form name prefix. Because of !s, the code will try to associate the fields with the object and of course that is wrong. Either remove the !s or use Me! or change the WITH object.

    With Me
    objOutlookMsg.Subject = ...
    objOutlookMsg.Body = ...
    DoCmd...
    objOutlookMsg.Display
    End With
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    June7,
    Thanks, I got it figured out. All I needed was to remove the "!" from the .Subject and .Body part of the codes.

    Thanks for the help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. runtime error 3134
    By TheLazyEngineer in forum Programming
    Replies: 2
    Last Post: 03-03-2015, 02:55 PM
  2. Replies: 2
    Last Post: 10-15-2014, 04:23 AM
  3. Access Runtime Error
    By DCMikado in forum Access
    Replies: 1
    Last Post: 06-24-2013, 10:07 AM
  4. Replies: 13
    Last Post: 06-12-2012, 09:52 PM
  5. Error in Runtime Only
    By drunkinmunki in forum Programming
    Replies: 7
    Last Post: 12-16-2010, 03:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums