object 91 variable ERROR

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David B

    #1

    object 91 variable ERROR

    I have an app running on a number of `puters in A97 with no problems.
    Has been running fine on 1 A2000 machine. Put an upgrade on tonight and got -
    91 object variable or with block variable not set - message. when running the
    following
    References seem Ok
    Compiles OK
    Any thoughts ?
    David B


    code below -



    Private Sub Command68_Click ()
    On Error GoTo Handler

    If (Me!Textcount) = 0 Then
    MsgBox "There are no records to send"
    Exit Sub
    Else
    DoCmd.OpenQuery "bcmsdeletebirt htable", acNormal, acEdit
    DoCmd.Close acQuery, "bcmsdeletebirt htable"
    DoCmd.OpenQuery "bcmsbirths ", acNormal, acEdit
    DoCmd.Close acQuery, "bcmsbirths "
    End If
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Dim strMessage As String
    Dim strsubject As String
    Dim strspareline As String
    Set rs = db.OpenRecordse t("BCMSREGgrab" )

    If Not rs.BOF And Not rs.EOF Then
    rs.MoveFirst
    Dim olObj As Outlook.Applica tion

    Dim olMail As Outlook.MailIte m

    Set olObj = New Outlook.Applica tion

    Set olMail = olObj.CreateIte m(olMailItem)


    Set olMail = olObj.CreateIte m(olMailItem)



    Do
    strMessage = strMessage & vbCrLf & Trim(rs![Tag No] & Chr(124) & rs![DateOB] &
    Chr(124) & rs![Sex] & Chr(124) & rs![Breeds] & Chr(124) & rs![electID] &
    Chr(124) & rs![Dam I D] & Chr(124) & rs![surrdamid] & Chr(124) & rs![Ear Tag] &
    Chr(124) & rs![Holding No] & Chr(124) & rs![birthherdsuffix] & Chr(124) &
    rs![Holding No] & Chr(124) & rs![postherdsuffix]) 'data
    strsubject = Trim(rs![BCMSapplicID] & Chr(124) & rs![BCMSVno] & Chr(124) &
    rs![BCMSorigionater ID] & Chr(124) & rs.RecordCount & Chr(124) & rs![timestamp])
    'header
    strspareline = ""
    rs.MoveNext



    Loop Until rs.EOF



    With olMail

    .Subject = ""
    .Body = strsubject & vbNewLine & strspareline & vbNewLine &
    strMessage & vbNewLine
    .To = "data@sis.defra .gsi.gov.uk"
    .Send
    End With
    Set olMail = Nothing


    End If

    exitsub:

    olObj.Quit
    Set olObj = Nothing
    rs.Close
    Set rs = Nothing
    Set db = Nothing
    MsgBox "Email has been created. Open Outlook then press F5 to dial"



    Dim stAppName As String

    stAppName = "C:\Program Files\Microsoft Office\Office\o utlook.exe"
    Call Shell(stAppName , 1)
    pbooClickTest = True
    Exit Sub

    Handler:
    Select Case Err.number
    Case Else
    MsgBox Err.number & " " & Err.Description
    Resume exitsub
    End Select


    End Sub


  • John Mishefske

    #2
    Re: object 91 variable ERROR

    What line do you get the 91 error? That's Object not defined I believe. The
    references may appear fine but you may not have a made a reference to a
    referenced type. Identifying the line would help much.

    David B wrote:[color=blue]
    > I have an app running on a number of `puters in A97 with no problems.
    > Has been running fine on 1 A2000 machine. Put an upgrade on tonight and got -
    > 91 object variable or with block variable not set - message. when running the
    > following
    > References seem Ok
    > Compiles OK
    > Any thoughts ?
    > David B[/color]

    <code snipped>

    --
    '-------------------------------
    ' John Mishefske
    '-------------------------------

    Comment

    • David B

      #3
      Re: object 91 variable ERROR

      Problem I have is this machine is a few miles away. Things run fine on all the
      local machines
      David B





      John Mishefske <mishej@execpc. com> wrote in message
      news:vm2abagn3t jp38@corp.super news.com...[color=blue]
      > What line do you get the 91 error? That's Object not defined I believe. The
      > references may appear fine but you may not have a made a reference to a
      > referenced type. Identifying the line would help much.
      >
      > David B wrote:[color=green]
      > > I have an app running on a number of `puters in A97 with no problems.
      > > Has been running fine on 1 A2000 machine. Put an upgrade on tonight and[/color][/color]
      got -[color=blue][color=green]
      > > 91 object variable or with block variable not set - message. when running[/color][/color]
      the[color=blue][color=green]
      > > following
      > > References seem Ok
      > > Compiles OK
      > > Any thoughts ?
      > > David B[/color]
      >
      > <code snipped>
      >
      > --
      > '-------------------------------
      > ' John Mishefske
      > '-------------------------------
      >[/color]

      Comment

      • John Mishefske

        #4
        Re: object 91 variable ERROR

        David B wrote:[color=blue]
        > Problem I have is this machine is a few miles away. Things run fine on all the
        > local machines[/color]

        The likely suspects are the variables that point to a DAO recordset and database and
        the Outlook object. This is most likely a reference issue - you need to set a
        reference to Microsoft DAO 3.6 Object Library (version dependent on your Access
        version) and a reference to Outlook. Alt-F11, Tools, References and search for these
        in the list and check them. If you find them marked as MISSING then un-click them,
        close the references window and go back in and click them.

        Check out: http://members.rogers.com/douglas.j....nceErrors.html


        --
        '-------------------------------
        ' John Mishefske
        '-------------------------------

        Comment

        Working...