locked
runtime error 91 object variable or With block variable not set RRS feed

  • Question

  • Hi

    I get the following error when I try to open a database stored on a networked/shared driver "runtime error 91 object variable or With block variable not set
      #10  
    ". 

    When I debug it opens VB and higlights the very last line :

        ' Open the table of Switchboard Items, and find
        ' the first item for this Switchboard Page.
        Set con = Application.CurrentProject.Connection
        stSql = "SELECT * FROM [Switchboard Items]"
        stSql = stSql & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" & Me![SwitchboardID]
        stSql = stSql & " ORDER BY [ItemNumber];"
        Set rs = CreateObject("ADODB.Recordset")
     > rs.Open stSql, con, 1   ' 1 = adOpenKeyset
       

    Please can someone tell me what i need to change to make this work?

    Thanks
    Tuesday, August 18, 2009 8:20 AM

Answers

  • Hi - turns out the problemw as with the regional settings!!

    thanks for your help

    cathy :0)
    • Marked as answer by Cathyb569 Tuesday, November 3, 2009 2:10 PM
    Tuesday, November 3, 2009 2:10 PM

All replies

  • You can check this link
    http://msdn.microsoft.com/en-us/library/aa264506(VS.60).aspx

    Also can you check if the sql server table has a primary key?

    I suggest you add an Else clause to that big If ... ElseIf block, or rewrite it as a Select Case block with a Case Else statement, and logic to handle the
    situation when none of the cases is met. You can also set a breakpoint at the top of that code and step through to see what happens, and examine the value of Me.OpenArgs in the debugger.

    Bhawesh Kumar MCTS, MCPD, MCPDEA
    Monday, August 31, 2009 3:26 PM
  • hi - sorry but i really have no idea when it comes to programming, would it be possible for you to amend the above and send me the changed syntax so i can just try to replace it?
    Thursday, September 10, 2009 7:59 AM
  • If you run the SQL query in query analyzer/management studio, does it execute okay?
    The error message is not an SQL one but a syntax error in your application language.
    George
    Thursday, September 10, 2009 9:44 AM
    Answerer
  • Thanks George, have you any idea what the syntax error might be?
    Tuesday, September 15, 2009 7:14 AM
  • I'm assuming Me![SwitchboardID] is null, causing you to pass a NULL sSQL value to the recordset object
    George
    • Marked as answer by Cathyb569 Tuesday, November 3, 2009 2:09 PM
    • Unmarked as answer by Cathyb569 Tuesday, November 3, 2009 2:10 PM
    Tuesday, September 15, 2009 11:26 AM
    Answerer
  • Hi - turns out the problemw as with the regional settings!!

    thanks for your help

    cathy :0)
    • Marked as answer by Cathyb569 Tuesday, November 3, 2009 2:10 PM
    Tuesday, November 3, 2009 2:10 PM
  • What did you have to change with the Regional Settings?
    ISUTri
    Friday, December 11, 2009 7:36 PM