+ Reply to Thread
Results 1 to 4 of 4

Run-time error 91 Object variable or with block variable not set

  1. #1
    Registered User
    Join Date
    09-08-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    2

    Thumbs up Run-time error 91 Object variable or with block variable not set

    I wrote a program in MS Access that when user clicks on a command button on the form, data would be extract from a query table into a new MS Excel worksheet using OLEDB.

    My error is strange because the error does not occur everytime I click on the command button and there is a patten when the error message appears. So first time I clicked on command button, MS excel worksheet will populate the data with no error. I closed the MS Excel worksheet, click on command button again and error message would come up. Third time no error message. Fourth time has the error message and so on.

    Here is my code: Grey color part isn't relevant so can be ignored I just didn't want to not display it in case it might matter. Red is where error occurs.
    Please Login or Register  to view this content.
    Last edited by Janoose; 09-09-2010 at 08:31 AM. Reason: add code tags

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Run-time error 91 Object variable or with block variable not set

    You can't just use an unqualified reference to ActiveCell - you need:
    Please Login or Register  to view this content.
    Note: when posting code you must use code tags around it. I have added them for you as this is your first post, but please use them in future.

    Thanks.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    09-08-2010
    Location
    Toronto
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Run-time error 91 Object variable or with block variable not set

    Hey thank you. It works now! Sorrie for not putting code tags, I never really post in forums so still new with the tags in general.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Run-time error 91 Object variable or with block variable not set

    Not a problem.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1