The Linux Page

Method 'item' of object 'forms' failed. MS-Access

As I was working on a project in MS-Access, I ran in a problem with this error which meant close to nothing, at least nothing to do with what I was working on.

The truth was that I had made changes in a parent form and the sub-form Load function would fail with that error. After a while I finally thought that the problem was probably with the fact that the parent was not compiling.

I used the Debug feature to compile everything and fixed the couple of errors I had to fix the problem. What the error in itself was is most certainly not relevant, although the two reasons for the mix up were that I added a Form_Unload function by hand, missing the necessary Cancel parameter. Not having such makes the compilation fail. Also I created a function assigning it a name that was also the name of a field. I think that was the main culprit because once I fixed that, everything returned to normal.

Function FieldName()
  FieldName = False
  FieldName = True
End Function

Where FieldName is also the name of a field in the form. Not a good idea! But when you deal with hundreds of fields...