Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Cornwall, England
    Posts
    393
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Object variable not set (XP)

    Hi,

    I have recently upgraded from 97 to XP and am having trouble with my first project. I used to type the code below and have no troubles what so ever, now however as soon is a reference the first row of the recordset i get
    error 91, object variable or with block variable not set

    Dim objDB as database
    Dim objRS as recordset
    Dim strSQL as String

    strSQL = "Select * from Table"

    set objDB = CurrentDB
    set objRS = objDB.openrecordset(strSQL)

    while not objRS.EOF <------ this is where the code falls over
    whatever actions i wanted
    wend

    set objRS = nothing
    set objDB = nothing

    i have a reference to Microsoft DAO 3.6 Object Library but am not sure what other reference i might need??

    can anyone help please?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Object variable not set (XP)

    FatherJack

    I had exactly the same problem some weeks ago. Have a look at this post, with some other references to help you <post#=263970>post 263970</post#>


    Jerry
    Jerry

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Object variable not set (XP)

    I would suspect that Access thinks that your Recordset is an ADO Recordset.

    Try changing your dims to:

    Dim objDB as DAO.database
    Dim objRS as DAO.recordset

    Both ADO adn DAO have recordset object and aren't interchangable.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

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