Results 1 to 4 of 4

Thread: [RESOLVED] connecting from outlook vba to access db through ado

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Sep 2005
    Posts
    586

    Resolved [RESOLVED] connecting from outlook vba to access db through ado

    hey,

    I'm trying to connect outlook to access through ado.

    I get runtime error 91: " object variable or with block variable not set" .

    here's my code (vba in outlook):

    ---------------------------------------
    VB Code:
    1. Dim AccessConnect As String
    2.       Dim Conn1 As ADODB.Connection
    3.       Dim Rs1 As ADODB.Recordset
    4.       Dim StrDbg As String
    5.      
    6.        AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _
    7.                      "Dbq=my_database.mdb;" & _
    8.                      "DefaultDir=P:\;"
    9.  
    10.       Conn1.ConnectionString = AccessConnect
    11.       Conn1.Open
    12.      
    13.       Set Rs1 = Conn1.Execute("SELECT * FROM Stations")
    14.       Rs1.MoveFirst
    15.       StrDbg = ""
    16.        
    17.        While Not (Rs1.EOF)
    18.             StrDbgp = StrDbg & "," & Rs1("station_no")
    19.             Rs1.MoveNext
    20.        Wend
    21.  
    22.        Rs1.close
    23.        Conn1.Close
    24.        Conn1.ConnectionString = ""
    -----------------------------------------

    any ideas why?
    Last edited by RobDog888; Dec 27th, 2005 at 02:02 PM. Reason: Added [vbcode] tags

Posting Permissions

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



Click Here to Expand Forum to Full Width