2003 code raises error in 2007

K

Kate

I have a reference in VBA to a subform of a subform, which works fine in
Access 2003.
In Access 2007, however, it results in "you have entered an invalid
reference to the property Form/Report."

This is the snippet of code:


Private Sub SetFormProperties()
'called from form_open, makes all forms editable if edit mode was selected

Dim ctrl As Control, ctrlSub As Control
Dim frm As Form

If Me.OpenArgs = "Edit" Then
Set frm = Me

'set main form edit options
EditProperties frm

'set subform edit options
For Each ctrl In frm
If ctrl.ControlType = acSubform Then
EditProperties Forms(frm.Name).Controls(ctrl.Name).Form
For Each ctrlSub In ctrl.Form

'subforms can have subforms!
If ctrlSub.ControlType = acSubform Then
EditProperties
Forms(frm.Name).Controls(ctrl.Name).Form.Controls(ctrlSub.Name).Form '
THIS IS THE LINE THAT CAUSES THE ERROR!!
End If
Next ctrlSub
End If
Next ctrl
End If
End Sub



Sub EditProperties(frm As Form)
'this only gets called when Edit mode is true, as forms are opened
read-only otherwise.

With frm
.AllowAdditions = True
.AllowEdits = True
.AllowDeletions = True
End With
End Sub


Thanks if you can help me,
Kate
 
A

AccessVandal via AccessMonster.com

Might be one of those quirks in 2007. Looks like references problem although
you might not have any missing references.

If compact and repair and recompiling your code did not work.

Here what we can do at least.

Go to Tools – References

Record down all the references you have. Delete all references and click OK
and exit the database.

Reopen your DB again, re-select your references again and exit your DB.

Open your DB again and test.

See if that works for you.

If it still doesn’t, do a decompile here a site on this.

http://www.granite.ab.ca/access/decompile.htm

Note: Do a back of your database first.
 
K

Kate

Thanks for the reply, but I think you misunderstand the problem. It is
the fully-qualified reference to the
form that is the problem, not a missing VBA reference.
 
A

AccessVandal via AccessMonster.com

Nonetheless, you might consider it. It a worthwhile try to get your DB
working.
 
O

o;;

AccessVandal via AccessMonster.com said:
Might be one of those quirks in 2007. Looks like references problem
although
you might not have any missing references.

If compact and repair and recompiling your code did not work.

Here what we can do at least.

Go to Tools - References

Record down all the references you have. Delete all references and click
OK
and exit the database.

Reopen your DB again, re-select your references again and exit your DB.

Open your DB again and test.

See if that works for you.

If it still doesn't, do a decompile here a site on this.

http://www.granite.ab.ca/access/decompile.htm

Note: Do a back of your database first.
 
O

o;;

AccessVandal via AccessMonster.com said:
Might be one of those quirks in 2007. Looks like references problem
although
you might not have any missing references.

If compact and repair and recompiling your code did not work.

Here what we can do at least.

Go to Tools - References

Record down all the references you have. Delete all references and click
OK
and exit the database.

Reopen your DB again, re-select your references again and exit your DB.

Open your DB again and test.

See if that works for you.

If it still doesn't, do a decompile here a site on this.

http://www.granite.ab.ca/access/decompile.htm

Note: Do a back of your database first.
 
O

o;;

Kate said:
Thanks for the reply, but I think you misunderstand the problem. It is the
fully-qualified reference to the
form that is the problem, not a missing VBA reference.
 

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