Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not enought memory error when opening a form 3

Status
Not open for further replies.

Mayhem9

Technical User
Dec 19, 2009
155
AU
Hello,

I have been working on a form and now I am getting a "There isn't enough memory to perform this operation..." error.

I am running 4GB of RAM and have no other programs running and have closed down all the sleepers in the system tray. Task manager shows 3% memory use. Opening other forms are fine and I can open the relevant table as well.

I have tried double clicking on it, opening in design view and even tried using a macro. All result in the same error. When the form is highlighted and I click on the code icon in the menu bar, I get the same error. However, If I open up a module I can then open the code.

So far I have tried the following:

1 - Compile the code (no errors)
2 - Compact and repair database
3 - Detect and repair
4 - Bad language

None are working - any suggestions?

Cheers,
Darren
 
Hi MajP,

Haven't managed to track down any books yet. Would you be able to post the ISBN for the Access Inside Out book that you have? As I am using Access 2003, it is probably a good one to get.

I am rebuilding the database I have the main form looking good and getting the functions that I want. However, I am hitting a brick wall and it is doing my head in.

The manufacturer combo box is called ManID but whenever I enter any code relating to this item the uppercase D is changed to a lowercase d, which is causing problems. I deleted the combo box and re-created it but the problem persists.

The pertinent combo box details are as follows:
Combo Box: ManID

Name: ManID
Control Source: ManID
Row Source Type: Table/Query
Row Source: SELECT Manufacturer.Man FROM Manufacturer ORDER BY [Man];
Any ideas on how to stop this from happening?

Also, the form code for FAYT combo boxes is throwing the following error:

91 Object variable or with block variable not set.

I thought it was the case issue described above but it happens with all 4 combo boxes. The code is exactly the same as when it was working:
Code:
Option Compare Database

Option Explicit
Public faytMan As New FindAsYouTypeCombo
Public faytType As New FindAsYouTypeCombo
Public faytLoc As New FindAsYouTypeCombo
Public faytPur As New FindAsYouTypeCombo

Private Sub Form_Load()
  faytMan.InitalizeFilterCombo Me.ManID, "Man", False
  faytType.InitalizeFilterCombo Me.TypeID, "Type", False
  faytLoc.InitalizeFilterCombo Me.LocID, "Loc", False
  faytPur.InitalizeFilterCombo Me.PurID, "Pur", False
End Sub

What am I doing wrong?
Cheers,
Darren.
 
Object variable not set means you are trying to use an object variable but it does not equal (set to) anything

Ex:
Dim myfrm as access.form
msgbox myFrm.name (at this point myfrm is does not equal anything)

but this works
dim myFrm as access.form
set myFrm = forms("someForm")
msgbox myFrm.name

all the find as you types get set here in the form load event. However, if that event does not fire then they never get set. If in the properties page of the form. The onload event does not have [Event Procedure} the event will not fire. My first debug step to to ensure I am hitting a procedure is to put
msgbox " ProcedureName Triggered"
at the top of the procedure.

However these are public variables. If you throw an error in your code and do not trap it all variables go out of scope.

Do not pay more than 20 bucks on a used version (with CD lots of code)

Not sure about the lowercase D, but it should not be a problem. The filter list should pull from your manufacturer tables (make sure you select limit to list in the properties). Does the manufacturers in the table all have lower id. Post it if you still have a problems.

Also the first parameter of the initialize event should be the combobox.
is manID the name of the combo
faytMan.InitalizeFilterCombo Me.ManID, "Man", Fals

It should still work, but I would give your controls different names than the associated fields (just good practice) cmboMan, cmboLoction...
 
Thanks MajP,

Yes, the name of the combo box is ManID, which (as you point out) is the name of the control source. I'll change the names and this is the basics that I need to learn (i.e. naming conventions for different things).

I looked at the event tab in the properties for one of the FYAT combo boxes and there are no [Event Procedures]. As I was unsure what type of even should be triggered, I checked a previous version in which the FAYT combo boxes were working and they didn't have any either! I double checked to ensure the combo boxes were in fact FAYT and they were.

I will have to look at this over the weekend, as time is getting on.

Thanks for the info on the book. I will see if the local library can source a copy until I can find one.

Cheers,
Darren
 
Reread my post
"all the find as you types get set here in the form's load event. However, if that event does not fire then they never get set. If in the properties page of the form. The onload event does not have [Event Procedure} the event will not fire."

not the combo event, the form event.
 
S#%T - I have got to stop working on this at 1am and beyond! Thanks for pointing that our MajP. I will look into it and try again.

Cheers,
Darren
 
Hi MajP,

There is an Event Procedure for Load when I look at the Form properties. When I click on it, I am taken to the fayt code, so at least I know the problem isn't that.

I am going to see what I can do over the weekend and I will try renaming the combo boxes, as you suggested.

I would have thought that copying code that worked into a new form that has all the same as the last would have been smooth sailing. Hang on a minute, didn't the Captain of the Titanic say just that?

Cheers,
Darren
 
Private Sub Form_Load()
' faytMan.InitalizeFilterCombo Me.ManID, "Man", False
' faytType.InitalizeFilterCombo Me.TypeID, "Type", False
' faytLoc.InitalizeFilterCombo Me.LocID, "Loc", False
' faytPur.InitalizeFilterCombo Me.PurID, "Pur", False
End Sub

comment all of these out so that they do not run. Then remove the comment one by one until you see which one through the error.

Then on the one that throws the error, keep it commented out. Likely the combo is not loading at all.
 
Hi MajP,

This is actually what I had been doing prior to previous posts and all four are throwing the error. If I leave all uncommented I get four error messages upon opening the form.

If two are uncommented then I get 2 error messages. The error also pops up if you click on a combo box and then again for every character you type (I usually stop after two).

I have deleted the Manufacturer combo box and re-created it but no joy. I'll keep working on it and let you know how I get on.

Cheers,
Darren
 
It is likely in my code. Can you post the db? I know you want to tough it out, but I can probably figure it out quickly. Do you really want all those FAYT? May not be worth the work.
 
Hi MajP,

Do you ever sleep? Thanks for offering to look at this. I have uploaded 2 files:

Current development version:

Archived working version:

I doubt it is your code, as it was working before I had the corrupted form and I exported the class module into the blank db that is the current working version. My money is on me missing something very simple.

The manufacturer list is long, as is the tool type, so the fyat is very handy for these two. I figured for an extra two lines of code it is worth using it for the other two. I did resist the temptation for the yes/no option!

I am contemplating changing the contents of the type table to conform with the categories commonly used by a few tool manufacturers. However, to do this I will need to use a sub type combo box as well. There is another thread (thread702-1586056) that covers filtering what is listed in the second combo box on the basis of what is selected in the first. I thought that I might try to do this but not until I get the base version sorted out and working. I am just wondering if the fyat would still work with this?

Cheers,
Darren
 
No it is in my code implementation instructions. Your development version works fine, if I open the tool log without any other forms open. If I move the intialization from the on load event to the form's on open event everything seems fine.

Private Sub Form_Open(Cancel As Integer)
DoEvents
faytMan.InitalizeFilterCombo Me.cmbMan, "Man", False
faytType.InitalizeFilterCombo Me.cmbType, "Type", False
faytLoc.InitalizeFilterCombo Me.cmbLoc, "Loc", False
faytPur.InitalizeFilterCombo Me.cmbPur, "Pur", False
End Sub

The forms order of events are:
Open ? Load ? Resize ? Activate ? Current

So what is happening the form opens and the variables are not yet set. However (which I do not understand) something is trying to call the class. Before the load event.

So I think the solution for initializing all of these objects is to use on on open event.

These class modules are really nice, because it only takes you a couple lines of code to get a lot of functionality. If you coded this it would take about 100 lines of code for each combo. But the drawback is it shields you from what is going on under the hood.

You can have cascading Find as you type, never done it.
 
one more important thing.
Always, always in the vba window select "Tools", "Options", "Require Variable Declaration"

This will put at the top of your modules
Option Explicit

which means you have to declare the variable

So now check each module and put this in. make sure not to do it twice in a module. Then hit debug compile, you will see some errors.

Here is why. Without this I can use a variable and never define it. But this is what can happen

dim strManufacturer as string
stManufacturer = cmboMan (notice st not str)
msgbox strManufacturer

And the msgbox returns nothing. You can get serious logic errors or runtime errors.

If I had option explicit, I would get an error telling me that "stManufacture" has not been declared. Without it I would never see the problem.

No other language that I know of allows you not to declare a variable. It is stupid that MS does.

The above issue is a real problem in the current db, so fix the option explicit.
 
Hi MajP,

Thanks for your help (again). It works perfectly. A copy saved to the archive.

Always, always in the vba window select "Tools", "Options", "Require Variable Declaration"

Done - I would have thought that this would have been something that should be checked by default? These are the sorts of tips that are invaluable and which I wouldn't find from pulling other databases apart (BTW: my library has that book on order).

I was all excited by your last post but unfortunately, I cannot open the bells and whistles. The file has an extension .accdb which I cannot open. If I try open with and choose Access, it says the database in unrecognizable. It also doesn't like it if I change the extension .mdb. I am using 2003 and I thing you are using 2007, so I wonder if it is a version compatibility issue? It isn't so much the bells and whistles either - just looking how to make life easier (otherwise I would have stuck with Excel) :)

Cheers,
Darren
 
OK - it is official; Access hates me.

In rebuilding this form I am introducing code piece by piece and I am encountering more errors.

This code is currently throwing an ambiguous name compile error for "BrowseFiles":

Code:
Private Sub AddImage_Click()
   Me!ImagePath = BrowseFiles
      If Trim(Me!ImagePath & "") <> "" Then
      Me!ImageFrame.Picture = Me!ImagePath
      End If
End Sub

The module modBrowseFiles is present and contains the following procedure:

Code:
Public Function BrowseFiles()
    Dim sSave As String

    sSave = Space(350)
    If IsWinNT Then
       GetFileNameFromBrowseW Screen.ActiveForm.Hwnd, _
                StrPtr(sSave), _
                350, _
                StrPtr("c:\Tools\Images\temp"), _
                StrPtr("jpg"), _
                StrPtr("jpg files (*.jpg)" + Chr$(0) + "*.jpg" + Chr$(0) + _
                    "All files (*.*)" + Chr$(0) + "*.*" + Chr$(0)), _
                StrPtr("Select Image")
                
    End If

    BrowseFiles = Trim(Replace(sSave, Chr$(0), " "))

End Function

Any suggestions?

Cheers,
Darren
 
ambiguous name compile"

Means you have a two procedures with the same name (usually a copy paste error)

Or you have a procedure and module with the same name.
procedure: "BrowseForFile"
module: "BrowseForFile"


Hit debug compile and it will hilite the problem.
 
also if the procedure is public it can not have the same name in two modules
This is usually the error when you start copying and pasting procedures and modules. You end up with the same procedures in two modules. Same problems with public variables.
 
Hi MajP,

Debug - compile was how I found it (dhookom put me on to that one!). It highlights "BrowseFiles" in the form code that I posted above (the first code).

What I haven't figured out is what to do next! Sometimes it gives me the option to step over (which I guessed would move on to the next problem) but it doesn't on this occasion

Using Ctrl F didn't turn up any other instances of BrowseFiles. I've just tried it again and got the same result.

Cheers,
Darren
 
Using Ctrl F didn't turn up any other instances of BrowseFiles
Even when searching the whole project ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hadn't seen your second post when I replied. I'm not sure if I have described things adequately, but the first bit of code is the procedure for the Add Image button in my Tool_Log form, which calls the modBrowseFiles module (which is API code if that makes a difference - thread702-1586784).

I imported modBrowseFiles and then inserted the button code when I created it in the form. I was pretty sure that I had worked through each function in the form step by step. It it was working before and now it isn't. I still think Access has it in for me!

Cheers,
Darren
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top