Run Time error 7: Out of Memory (1 Viewer)

chshiba

New member
Local time
Yesterday, 18:00
Joined
Apr 11, 2007
Messages
3
Im building a new database using Access 2003 SP2 on windows XP SP2 with 1 GB RAM.

When i try to execute the following line of VBA code I get an "out of memory" error:

Code:
Form_Confirmation.txtDept = cboDept.Text

Before this line of code I don't query any data or open any DAO connections, Im only checking the entered values in various text boxes and combo boxes on a form. I have also tried rebooting my computer and it still gets stuck at the same line.

What i basically want to do is just move data entered into text boxes on a shipping order form i created and present that data on another form to confirm the entered data. The error occurs when i try to move data from one form to another. The database is still only 1MB with only 5 tables, each with only a few records in them just for testing.

Do i need to install a service pack or download something to fix this error?
 

WayneRyan

AWF VIP
Local time
Today, 02:00
Joined
Nov 19, 2002
Messages
7,122
C,

The reference "cboDept.Text" is only valid in the OnChange event for
cboDept. It is not a valid elsewhere.

You can substitute .Value (for the .Text), but that's the default anyway.

Wayne
 

chshiba

New member
Local time
Yesterday, 18:00
Joined
Apr 11, 2007
Messages
3
Thanks for taking the time to reply wayne,

I tried using cboDept.value and just cboDept but i still get the same error.

I got rid of the error but i dont know how. I copied and pasted the code and controls to a new form and now it works fine. The code and controls are exactly the same, except now it is running on a new form. I just don't get it.

I've searched this forum, google, and google groups and i have seen a lot of people get this error for different reasons with no solution. Does anyone know where this error comes from and how to rectify it or ways to avoid it?
 

WayneRyan

AWF VIP
Local time
Today, 02:00
Joined
Nov 19, 2002
Messages
7,122
CH,

Don't use .Text

I cant believe how hard that was to type.

W...
 

boblarson

Smeghead
Local time
Yesterday, 18:00
Joined
Jan 12, 2001
Messages
32,059
For one, you have referenced:
Form_Confirmation.txtDept = cboDept.Text

And unless your form is actually named "Form_Confirmation" you would want to references it either:
Code:
Forms!Confirmation.txtDept = Forms!Confirmation.cboDept
or, if txtDept is on the same form as cboDept
Code:
Me.txtDept = Me.cboDept
but I suspect since you are wanting .Text, you are wanting the displayed value, which is probably not the bound column (which is probably the ID), so you would want:
Code:
Me.txtDept = Me.cboDept.Column(1)

I suspect the actual problem lies in that you were using Form_Confirmation which is what shows up in the Project Explorer window, but is not how you reference the form.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:00
Joined
Feb 28, 2001
Messages
27,147
"Out of memory" errors occur when, for some reason, Access runs out of memory. (OK, guys in the back room, no snickering....) So what actions can lead to this?

Well, the first thing to consider is that memory comes in two flavors for Access. There is the object that you actually store in the database. Then there is an object that represents something external to the database file but that exists for the duration of Access execution in RAM.

I believe this error applies to something that is NOT a stored database object like a table, query, etc. etc. It is more likely a dynamic object. For instance, the kind of object you create using CreateObject("Application.Excel") or whatever other apps you might use.

You could also do this with a dynamic array created by calling a subroutine in a module where that module locally declares a huge array.

Basically, you have run into a memory limit that is going to be either physical memory (for something that currently cannot be paged), virtual memory (because the swap file is full), or program buffer memory (because you reached a limit on the number of allowed dynamic data buffers.) This will be hard as heck to figure out. There are a few places to look, though.

Usually, you can get to some useful data in XP to help diagnose some of these problems. Your best tools will be these items:

Run >> Accessories >> System Tools >> System Information

and

Run >> Control Panel >> System >> Advanced (tab) >> (Performance) Settings >> Advanced (tab) and look at the bottom for Virtual Memory.

and

Task Bar (right-click) >> Task Manager >> Performance (and >> Processes)

From System Information on the System Summary screen (top of the display tree) several lines down (just after Time Zone) you will see several lines devoted to memory issues. That gives you an overview of how much physical and virtual memory you are using. If you drilled down through Software you could get a list of what is physically present in memory. Be prepared to be sick at all the crud that Bill Gates allows into memory.


From the Task Manager Performance screen, you can see how much physical memory you have left. It is in the lower part of the display under the graphs.

From Task Manager Processes, you can see what processes are in physical memory and what priority has been assigned to each.

From the Control Panel path leading to Virtual Memory, you can see how much of your disk has been set aside for page/swap space. If you have less space set aside than 1/2 of your system's total physical memory, you have too little. Many authorities say you need an amount equal to your physical memory and I don't disagree.

You get an "out of memory" error when you have depleted the memory on your system and too many things of higher priority (device drivers, e.g.) are loaded to memory. Access will try to keep as much as it can in memory but some things (like dynamically created objects) cannot ever go into the MDB file. For instance, your WORKSPACE must be resident. Open file buffers must stay resident. Device driver data structures must stay resident.

Now, the question is whether you have things active in your database that are space eaters. Like opening BE/FE files. (OK, good idea but takes up extra memory for a second set of buffers for the extra workspace.) Like having linked objects active (because active object context ain't cheap). Like having pictures active (because picture mapping is very memory-intensive). Like having a really complex form active (because if it is busy enough, the collection of controls that has to be in memory for an open form can get quite big.

Things that eat your socks behind the scene are dynamic string creation and deletion in VBA modules. The string paradigm is such that strings are dynamically pulled from a structure called the HEAP. If you replace a string with a new string without overlaying it, you essentially deallocate a string, allocate a new string, and adjust the string variable to point to the new string value. Even though the old string value is de-referenced, it is not always safe to deallocate it. So old strings build up a lot. This might be relevant to what you are doing if it is a string value that always locks you up. The question is, is it always the same string value for the same record, or has something been found that changes WHICH record stops you. (Not which line of code... which RECORD that the code was handling.)

If you exhaust the heap or otherwise heavily constrain it by using it a lot, you can deplete memory. If you have a lot of subroutines with complicated private variable declarations, you use up a lot of stack space. The stack and the heap start from opposite ends of your virtual address space and work towards each other, generally. If they ever meet, you are out of memory.

Why didn't I give you more specifics? Because everyone's probems are very different. I can only tell you principles and places to look. You are the one who has to sit in front of the keyboard to shut down the situation that causes this problem.
 

Dennisk

AWF VIP
Local time
Today, 02:00
Joined
Jul 22, 2004
Messages
1,649
another way of running out of memory in access is having to many nested queries. So you may develop on a PC with 1gb and your nested queries run fine. Then you transfer to the production PC with 258kb of memory and your nested queriey runs out of memory.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 20:00
Joined
Feb 28, 2001
Messages
27,147
Dennisk, good call! That eats memory too, because EACH QUERY stays open until the parent closes.
 

Users who are viewing this thread

Top Bottom