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

    Errors

    I got this off the web and I am trying to set this up for my own uses. I get Error "91 Object variable or With Block variable not set."

    I am wanting the option to edit email before sending and using outlook to put in email addresses. I will set up the formatting with the VBCRLF/ CHR(10)/(9) and so forth afterwards

    Database Name: NIE 15_2 CRs
    Table Name: Change Request
    Query: GO_Email
    Fields (partial list): CR_Numbers, Date Issue Identified, Change Request......

    Dim db As Database
    Dim rstNIE_15_2_CRst As Recordset
    Dim strSQL As String
    Dim strSubject, strBody As String
    Set NIE_15_2_CRs = CurrentDb()
    strSQL = "SELECT * FROM GO_EMail"
    Set rstNIE_15_2_CRs = db.OpenRecordset(strSQL, dbOpenDynaset)
    If Not rstGO_Email.EOF Then
    strBody = "This Change Request" & vbCrLf & vbCrLf
    strBody = strBody & "Date CR Number Change Requested" & vbCrLf
    strBody = strBody & "==================================" & vbCrLf
    rstGO_Email.MoveFirst
    Do While Not rstGO_Email.EOF
    strBody = strBody & rstGO_Email("CR_Numbers") & Chr(9) & _


    rstGO_Email("Date Issue Identified") & Chr(9) & _
    rstGO_Email("CR_Numbers") & Chr(9) & _
    rstGO_Email("[Change Requested]") & vbCrLf
    rstGO_Email.MoveNext
    Loop
    End If
    strSubject = "ALLCON,Here's my report!"
    DoCmd.SendObject acSendNoObject, , acFormatTXT, , , strSubject, strBody, True
    Exit Sub

    Thanks

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    See the error corrected in red
    Code:
    Set db = CurrentDb()
    strSQL = "SELECT * FROM GO_EMail"
    Set rstNIE_15_2_CRs = db.OpenRecordset(strSQL, dbOpenDynaset)
    Use Option Explicit at the top of module to avoid these errors

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Thanks amrut,
    I didn't post all of the program, so I didn't have the Options Explicit statement. I have updated to the following:

    Dim db As Database
    Dim rstChange_Request As DAO.Recordset
    Dim strSQL As String
    Dim strSubject, strBody As String
    Set db = CurrentDb()
    strSQL = "SELECT * FROM GO_EMail"
    Set rstChange_Request = db.OpenRecordset(strSQL, dbOpenDynaset)
    If Not Change_Request.EOF Then


    Here I get the error "Method or data member not found"

  4. #4
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    839
    Fixed the issue. Google and restart.

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

Similar Threads

  1. Replies: 4
    Last Post: 06-21-2014, 05:43 AM
  2. Run Time Errors
    By Stephanie53 in forum Access
    Replies: 7
    Last Post: 03-27-2013, 07:48 AM
  3. Please Help Runtime Errors :[
    By jamesgarf in forum Forms
    Replies: 3
    Last Post: 10-02-2012, 04:38 PM
  4. Replies: 10
    Last Post: 07-25-2011, 12:07 PM
  5. SQL that errors in VB
    By Wayne311 in forum Programming
    Replies: 3
    Last Post: 02-14-2011, 10:17 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