- Local time
- Today, 17:01
- Joined
- Sep 12, 2006
- Messages
- 16,096
Doc.
Yes, post a link if you like but there is already something on this site which might help:-
http://www.access-programmers.co.uk/forums/showthread.php?t=225415
There is even a demo for people to test. And on my SkyDrive site there are plenty more demos which use pointers to other Objects, all the OpenArgs demos.
----------
But you were also talking about the need to close recordsets and set them to Nothing. While under some circumstances that might be necessary it generally isn’t.
We can all post links to people who say it is necessary and some of us can post links to people who say it isn’t necessary. So what I was wondering about is if you could prove that it is necessary via a posted demonstration database.
----------
But about the use of the word Set. Your post restates that it is required. Well, it is required sometimes but not all. So the question was; why does the compiler require it sometimes but not all?
Chris.
Chris. Releasing memory using set obj = nothing
I think this example is correct. hopefully it is testable.
not a recordset, but releasing memory used by an object.
I have code that iterates all my forms to make design amendments - eg, change the form background to a standard setting
Code:
dim frm as form
dim obj as object
for each obj in currentproject.allforms
'it seems to be an object, not a form, so you have to do this in 2 steps
DoCmd.OpenForm obj.Name, acDesign
[COLOR=blue] Set frm = Forms(obj.Name)[/COLOR]
make changes
DoCmd.Close acForm, frm.Name, acSaveYes
[COLOR=red] Set frm = Nothing [/COLOR]
DoEvents 'tidies up the display
next
I thought the statement in blue would just reassign the frm variable each time - but it doesn't seem to release the memory unless I explicitly include the red line as well.
if I do not have the set frm = nothing statement, then eventually the programme crashes with an out of memory error, whereas if I do have it, it does the lot.
We are talking about a biggish application with several hundred forms, and I presume it is also dependent on the amount of memory actually available.
I was processing my forms in batches of 50 or so, until I realised that releasing the memory seemed to make a difference.
-----
with regard to forcing the use of the keyword SET. The "why" must just be the way the compiler is written. If some particular examples of using objects do not require set - then it must just be because the compiler writers didn't force the keyword to be required in certain instances. ie the compiler can generate the p-code, or assembler code without needing the token "SET" in some instances. (my terminology is probably incorrect, but I am sure the thought process is valid)
a compiler is just another program after all, is it not?