Referring to subforms

  • Thread starter Thread starter Karen
  • Start date Start date
K

Karen

I swear this was working just fine and yesterday it started throwing this error

Method 'Form' of object '_SubForm' failed

The VBA code on this form that is triggering the error is

Me.TestCompanyMain.Form.AllowAdditions = True

TestCompanyMain is the subform control on a main form. I've searched microsoft.com and can't find an answer, any ideas?

Karen
 
Karen said:
I swear this was working just fine and yesterday it started throwing
this error

Method 'Form' of object '_SubForm' failed

The VBA code on this form that is triggering the error is

Me.TestCompanyMain.Form.AllowAdditions = True

TestCompanyMain is the subform control on a main form. I've searched
microsoft.com and can't find an answer, any ideas?

I suspect some sort of corruption in your VB project. I'd make an
immediate backup copy of the database, then first try the Compact &
Repair function, and if that doesn't work I'd try decompiling,
compacting, compiling, and compacting again. To decompile -- which
should only be done if you've got a good copy of the database, just in
case it makes things works -- you can use Start -> Run to execute the
command line

msaccess.exe "C:\Your Path\YourDB.mdb" /decompile

You may or may not need to specify the path to msaccess.exe.

If that fails, I'd try creating a new blank database and importing all
objects into it.
 
Thanks Dirk,

I tried all suggestions and it didn't make a difference. I'm a little
concerned that this happened with two databases yesterday, first the primary
one, then it's backup. I've gone back to the backup made on Sunday and the
problem isn't there.

In your experience, is this likely to be corruption just in the database or
a more general problem that may require reloading the software?

Karen
 
Karen said:
Thanks Dirk,

I tried all suggestions and it didn't make a difference. I'm a little
concerned that this happened with two databases yesterday, first the
primary one, then it's backup. I've gone back to the backup made on
Sunday and the problem isn't there.

In your experience, is this likely to be corruption just in the
database or a more general problem that may require reloading the
software?

I haven't got that much experience with corruptions, so I'm only
reasoning about it here, but it seems to me that if the problem does not
exist in Sunday's backup, the corruption is probably in the database and
came into being between Sunday's backup and Monday's.

Is this a split database (tables only in the back-end .mdb, all other
objects in a front-end .mdb linked to the back-end)? If so, your data
should be safe but restoring Sunday's backup of the front-end should put
you back in business -- though any design changes since then will have
to be done over. If it's *not* a split database, I would take a copy of
Sunday's backup and try importing all the data (or all the new data)
from the current, corrupted, .mdb file. If, as I suspect, the
corruption is only in the VB project, the current database's tables
should be okay.
 
Dirk Goldgar said:
I haven't got that much experience with corruptions, so I'm only
reasoning about it here, but it seems to me that if the problem does
not exist in Sunday's backup, the corruption is probably in the
database and came into being between Sunday's backup and Monday's.

Is this a split database (tables only in the back-end .mdb, all other
objects in a front-end .mdb linked to the back-end)? If so, your data
should be safe but restoring Sunday's backup of the front-end should
put you back in business -- though any design changes since then will
have to be done over. If it's *not* a split database, I would take a
copy of Sunday's backup and try importing all the data (or all the
new data) from the current, corrupted, .mdb file. If, as I suspect,
the corruption is only in the VB project, the current database's
tables should be okay.

I'd like to add one thought -- if you hadn't said that Sunday's backup
works fine today, I would have entertained the idea that it's an
installation-related problem; possibly a broken reference or a damaged
installation of Access. But under the circumstances you describe, I
can't see how that could be, unless you added some reference -- an
ActiveX control, perhaps -- between Sunday and today, and now that
reference is broken. Did you do any programming in the database since
Sunday?
 
Dirk,

Thanks for the suggestions. I'll cross my fingers that this problem doesn't
resurface. This is still a database in the building stages so it isn't
split and the data is nothing but test data. Also, coincidentally, I was
pretty lazy yesterday so not much progress was made in design, just enough
to corrupt the work! Lesson learned and glad I backup several times a day.

Karen
 
I'm by no means an expert on this but have you tried
Me!TestCompanyMain.Form.AllowAdditions = True

Since TestCompanyMain is not a property of Me (your current form), I think
it should be preceeded with a "!" instead of a dot.

"!" is used to reference an object or control whereas a dot "." is used to
reference a method or property.

I have had cases where using the dot worked in one database but not in an
exact copy.
 
Hi again,

The only programming I did was adding buttons to a form and they were just
'open this form' buttons.

If my Sunday one gets corrupted in the near term, I'll reinstall Access
'just in case'.

Karen
 
Hi Chuck,

I tried your suggestion with the exclamation point and it made no
difference. Thanks, however, for the explanation, I'm perpetually in a
learning mode lately.

Karen
 
Hi Karen,

Thanks for your post. As I understand that the error message "Method 'Form'
of object '_SubForm' failed" occurred recently with VBA code in Access
Database. The database worked fine before. If I have misunderstood, please
feel free to let me know.

Based on my research, this behavior mostly can result from a damaged or a
corrupted Microsoft Data Access Components (MDAC) stack. I would like you
to download and install the latest version of MDAC (based on my experience,
MDAC 2.71 SP1 Refresh is recommended) from the following Microsoft Web
site:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/dataaccess
..asp

This site also provides links to information about how to install MDAC.

Thanks for using MSDN newsgroup.

Regards,

Michael Shao
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top