Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Runtime errors relating to unreleased references?

Hi,

I have a wb with 11 user forms - the forms are linked to one another
through the use of command buttons.
My first form (userform1) is a calendar (dynamic control sources set
for textboxes relating to a ws in my wb where the calendar entries are
stored). This userform has a command button which hides userform1 and
opens userform2. Userform2 has some buttons to run some code. At the
end of this code userform2 is hidden and userform1 is shown again.
Userform1 has userfrom_activate code that then runs.

This has worked fine for approx 1 week, however now I am getting run
time errors in the code that re-opens userform1 after userform2 is
hidden. From some research I believe this is due to unreleased object
references.

The error I am currently getting (although I have had other similar
ones at the same point) is;

Run-time error '-2147417848' Method 'select' of object 'range' failed.

I've read the MS help article on "Excel automation fails second time
code runs". If I am understanding correctly this is because the code
my userform2 is running is setting a reference to an object variable
and then not releasing it - then when userform1 is re-activated (and
the userform_activate code runs) this causes a problem. However I am
not clear on how to fix this issue.

Is referring explicitly to my objects enough;
activeworkbook.sheets("sheet1") instead of (sheets("sheet1") which is
how I have written my code)

OR

do I need to set a variable to the worksheet and wb;

dim xlsheet as excel.worksheet
dim xlbook as excel.workbook
set xlbook = "Planner.xls"
set xlsheet as xlbook.worksheets("sheet1")

and then set xlsheet as nothing

etc etc at the end of each sub?


Also does this apply to the way i refer to my userforms (currently I
have simply referred to them;
userform1.controls("Textbox1")

etc etc.

I'd appreciate any help on this as I am tearing my hair out?
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debugging runtime errors mmcstech Excel Discussion (Misc queries) 0 May 1st 07 05:34 AM
Find and set references at runtime rezafloyd Excel Programming 1 December 8th 06 02:34 PM
I am getting runtime errors in exel 2002, using old excel 97 temp EdD Excel Discussion (Misc queries) 0 February 10th 06 04:16 PM
VB runtime errors... savvysam Excel Discussion (Misc queries) 7 September 1st 05 02:42 AM
Sub Concatenate runtime errors savvysam Excel Programming 0 August 26th 05 10:48 PM


All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"