Out of Memory (Runtime Error 7)

chappy

Registered User.
Local time
Today, 06:33
Joined
Nov 5, 2003
Messages
30
I've made a custom progress meter which has worked fine until yesterday. Everytime I call or update the custom meter it I get an out of memory error. This is happening on every system I've tried to run the program on. All of the systems have ample RAM, and on my home system, Access is one of only 4 processes running with 256 Mb of available ram. This makes me think that it's not a problem with the amount of system RAM, but with the 64k memory segment limit, about which i know very little beyond what the Ms Access help describes. I've read that reducing module size helps to avoid exceeding the 64K limit, however the module producing the error is only 10 lines long. Anyone have any coding tips for freeing up memory?

P.S I had been using the built-in status bar (which never had this problem) however the custom meter looks better and allows me to be much more descriptive, especially with long and involved sub-routines.

Thanks for any and all suggestions.

-Chappy
 
The Code...

Here's the code...
Public Sub main(prcnt As Integer, Optional frm_caption As String, Optional tsk_caption As String, Optional cls As Integer)

If prcnt > 100 Then prcnt = 100
If prcnt < 0 Then prcnt = 0
If prcnt = 0 And tsk_caption <> "" Then DoCmd.OpenForm "progress_meter"
If frm_caption <> "" Then Form_progress_meter.Caption = frm_caption
If tsk_caption <> "" Then Form_progress_meter.Label10.Caption = tsk_caption
Form_progress_meter.Image2.Width = prcnt * 43.2
Form_progress_meter.Repaint
If prcnt = 100 And cls = 1 Then DoCmd.Close acForm, "progress_meter"

End Sub

Thanks,

-Chappy
 
Chappy,

The only way that you would get these kind of errors is if you
had code that was "recursively" calling itself.

The heading is "main..."

Where are you calling it from? Are you using the form's timer
event?

Can you post a sample?

Wayne
 
I would look elsewhere for this problem. Memory hogs that often get in the way:

1. Close what you open.
2. Release what you allocate. (Talking about creating dynamic arrays, among other things.)
3. Watch out for string operations involving really long memo fields.
4. Recursion of non-event code.

Also, check the amount of free space on your disk. That will govern how big a virtual memory area you can create. If it is too small, you run into your limits sooner. (Though I would have expected a different error message if the latter problem is the real cause of the failure. That's why I didn't include it in the list.)
 
Just out of curiousity.. why all the fuss to create a personal progress bar? why not just use the ActiveX progress bar control? I hear all the time of people saying its buggy or that it doesn't work for them but I have used it time and time again without any problems what-so-ever... Plus - all you have to do with this control is populate it...

Kev
 
Thanks everybody for all of the suggestions, and sorry for disappearing yesterday, I changed my email address and had to reactivate my account.

I am calling the progress meter sub from within a loop, however I'm not calling it recursively (at least as far as I understand what recursively calling a function means, I'm not), and i'm not using any timer event. For example I'm calling the sub with code such as:

sub recordset_loop()

dim rs as recordset,prcnt as integer,j as integer

call progress_meter.main(0,"Looping throug recordset","Fun, eh?")

set rs = currentdb.openrecordset("table_name")

rs.movelast

rc = rs.recordcount
j = 0
prcnt = 0
rs.movefirst

do until rs.eof
j = j + 1
if j mod 10 = 0 then prcnt = prcnt + ((j/rc) * 100)
call progress_meter.main(prcnt,,,1)
rs.movenext
loop

if prcnt < 100 then call progress_meter.main(100,,,1)

rs.close

set rs = nothing

end sub

I'll investigate all of your suggestions. I try to free up memory whenever I should in my coding, but there's a chance I missed some things, especially with the dynamic arrays. I have never used the ActiveX Progress bar (which I'm assuming is different from the Access status bar), so I'll look into that. The main reason I wanted to use a custom progress bar was that I could make it look much nicer than a default windows progress meter. Thanks guys!

-Chappy
 

Users who are viewing this thread

Back
Top Bottom