Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2010
    Location
    Perth Western Australia
    Posts
    7

    Object variable or With block variable not set problem

    Hi
    Can anybody help me get past this problem. I keep getting an " Object variable or With block variable not set run time error 91"
    here is the code. Any help most apreciated. All I want to be able to do is remember a record Id close the form and go to another form then return to the form and have the form display the remembered record.
    Thanks Steve



    Dim rs As Recordset
    Set rs = Me.Recordset
    QuoteNumberLng = 16 ' This is a public variant variable set to 16 for testing but could be any QuoID Number
    If TogQuoteCalc = 0 Then


    Forms!frmMain!frmQuote.SourceObject = "frmQuote"
    Forms!frmMain!frmQuote.SetFocus
    Forms!frmMain!frmQuote.Form!QuoID.SetFocus
    rs.FindFirst "[QuoID] = " & CStr(QuoteNumberLng)
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    End If

  2. #2
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    first off, you have 2 If statements but only one End If.

    second, what are you trying to do with set rs = me.recordset? are you trying to bind the form's recordset to rs or create rs and populate it with the form's recordset?

  3. #3
    Join Date
    Aug 2010
    Location
    Perth Western Australia
    Posts
    7
    Have one if and end if and the other is a nestled if then statement
    All I am trying to do is remeber the QuoID Number into a Public variable called QuoteNumberLng
    then close the form and do stuff then go back to the form and have it display the record with the QuoID remebered by the variable

  4. #4
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    my apologies about the IF part. busy day =P

    I'm assuming you've dim'd QuoteNumberLng and TogQuoteCalc.

    I havn't come across this issue personally so I did some research. I believe that it's not liking the way you initialized your recordset. try specifying a type. ADO or DAO. I'd check that first and continue researching. Sorry to say that I can't help much more. Hopefully someone who has come across this error can be more helpful.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I would agree about disambiguating the recordset declaration, and I suspect you need recordset clone rather than recordset. Here's the code the wizard would create to do what you're doing:

    Dim rs As Object
    Set rs = Me.Recordset.Clone
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. How to dereference a variable.
    By evander in forum Programming
    Replies: 6
    Last Post: 07-03-2010, 09:16 AM
  2. Object variable not retaining value
    By tuna in forum Programming
    Replies: 0
    Last Post: 05-21-2010, 05:38 PM
  3. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  4. Object variable...Jesus!
    By Baba78 in forum Access
    Replies: 8
    Last Post: 06-19-2009, 03:56 PM
  5. Variable question
    By synapse5150 in forum Programming
    Replies: 1
    Last Post: 07-09-2008, 08:17 AM

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