Main form with subforms

  • Thread starter Thread starter DNuding
  • Start date Start date
D

DNuding

I have created a DB with a main form and on this form I have 2 sets of tabbed
boxes with subforms on each tab.

Each set of tabbed controls are linked to the main form with the same
child/master field (Back#).

There is no problem adding the record with the 1st tabbed control forms.

On the 2nd tabbed control form, I can add records with the 1st and 2nd
forms, but when I get to the 3rd form, the financial form, I enter the Back#
in the Back# field and get this error,

"An errof occurred while referencing the object. You tried to run a Visual
Basic procedure that improperly references a property or method of an object."
If I click ok, the Back# I entered is there and I can continue entering the
data with no problem.

I have looked over all of the properties of the main form, tabbed controls
and each form and cannot figure out why I am getting this error.

Any idea where I can begin to troubleshoot this error?

Thanks for all help in advance.
 
...but when I get to the 3rd form, the
financial form, I enter the Back#
in the Back# field ...

If Back# is the foreign-key field that links the sub-form to
the main form, then it seems odd that you're having to enter
this number manually.

(As you no doubt know:) Normally you'd link a sub-form to
its main form using the master/child properties of the
subform control.

(Speculating:) I don't know if you're prevented from using
the normal linking technique because your sub-forms are on a
tabbed control. If so, there is a technique for linking
sub-forms to main forms that doesn't use the master/child
properties.
...and get this error,

"An errof occurred while referencing the
object. You tried to run a Visual Basic
procedure that improperly references a
property or method of an object."

Is there a code module behind the financial subform?

The sub-form's Current event fires when the record changes
in the sub-form. If the sub-form has a Current event
procedure, what is it doing?

Is there any other invalid code in the sub-form's code
module?


Geoff



message
 
Thank you GeoffG for your reply.

I checked and there is a Master/Child link from the main form to this
subform on Back#.

I could not find any code behind this subform. There is no code for the
Current Event. Should there be code for the subform Current event? If so,
what would it be? This form is created from a Select query that gets its
fields from 3 tables. It also does a lot of financial computations. It is a
single view form.

The relationship of the tblHorse (main form) to tblFinancial (subform) is a
one to many on Back#.

Is there anything else you can suggest?
 
1.
I checked and there is a Master/Child link
from the main form to this subform on Back#.

That sounds as it should be.
However, in your first post, you said:

2.
On the 2nd tabbed control form, I can add
records with the 1st and 2nd forms, but
when I get to the 3rd form, the financial form,
I enter the Back# in the Back# field and get
this error:
"An errof occurred while referencing the object.
You tried to run a Visual Basic procedure that
improperly references a property or method of
an object."
If I click ok, the Back# I entered is there and
I can continue entering the data with no problem.

The Back# field should be completed automatically by Access;
that is, you shouldn't enter the Back# in the Back# field
manually.

You could make it impossible to enter a Back# number
manually. Set the Enabled property of the Back# control (a
TextBox?) to False.

3.
Should there be code for the subform Current event?

No, there doesn't need to be code behind the sub-form. If
you had code, I wondered if it was giving rise to the error.

4.
This form is created from a Select query
that gets its fields from 3 tables.

Are you doing something illegal here?

You need to have a one-to-many relationship between the main
form and the financial sub-form. Can such a relationship
properly exist? (Somehow, I doubt it.)

Consider the table providing data to the main form and the
three tables in the Select query. Check the relationships
window. What is the line of relationships between all these
tables?

Is your database is properly normalized?

5.
I assume you change records in the main form and the
sub-forms using the appropriate Record-Navigation buttons in
each form.


Geoff



message
 
Back
Top