Run-Time error 2455

G

Guest

error 2455 Invalid reference to the property Form/report.
I have a form with a subform that has another subform. The code that caused
the error is
Dim frm as Form
Set frm = Forms.CashBook.TransactionAddMaster.Form .TransactionAdd.Form
I tried
Set frm = Forms.CashBook.TransactionAddMaster.Form
frm.TransactionAdd.Form.Period.DefaultValue = CurrentPeriod
The first line was ok but the second gave the same error.
I have an old db with the same setup and the code is working fine.
The object Browser sees the relationship ok. VB sees it to (in a dim as
forms_TransactionAdd). I've checked the form desgn mode and it sees it as a
subform control and a form.
I'm stuck Please help.
 
A

Allen Browne

First up, let's make sure that this is not a corruption.

1. Uncheck the Name AutoCorrect boxes under:
Tools | Options | General | Name AutoCorrect
Explanation of why:
http://allenbrowne.com/bug-03.html

2. Compact the database to get rid of this junk:
Tools | Database Utilities | Compact

3. Close Access. Make a backup copy of the file. Decompile the database by
entering something like this at the command prompt while Access is not
running. It is all one line, and include the quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

4. Open Access, and compact again.

If the problem still persists, let's ask Access what's going on.

1. Open the CashBook form.
2. Open the Immediate Window (Ctrl+G), and enter:
? Forms.CashBook.TransactionAddMaster.Form.TransactionAdd.ControlType
That should yield 112 (the value of acSubform.)

If not, track down what has the name, or what the real name of the subform
control is. (Of course the subform control can have a name different from
its SourceObject (the form loaded into it.))
 
G

Guest

I was just going to post an update when I got your post.
I forced the issue by bypassing all the statements and when the form
displayed I changed focus to another subform and then back again.(which sent
it through the same routine. It worked fine. The short story is the
sub-sub-form was not opened. Part of my code updated the recordsource of its
parent and it opened and all was well.
Next question I thought all the forms opened after the main one. I must have
been lucky in my old BB.
Thanks a lot for your help
 
T

tina

actually, just the opposite - a subform opens and loads before its' parent
form. as for multiple subforms on one parent form, i don't know if there is
a predictable order to which subform opens first - it may follow the tab
order of the subform controls, but i'm just guessing.

hth
 
M

Marshall Barton

tina said:
actually, just the opposite - a subform opens and loads before its' parent
form. as for multiple subforms on one parent form, i don't know if there is
a predictable order to which subform opens first - it may follow the tab
order of the subform controls, but i'm just guessing.


Tina, FYI

I believe that subform's are loaded in the order that the
subform controls were added the the main form. But, IMO,
that's too nebulous (Cut/Paste can change it) to rely on. A
possibly(?) better way to control the order of loading is to
leave the subform controls' SourceObject property empty and
fill them in the desired order in the main form's Load
event.
 
T

tina

in situations where the order of loading is important, that sounds like a
good idea. thanks Marsh :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top