Accessing Subforms through mainform isnt working???

sgtblitz

Registered User.
Local time
Today, 01:49
Joined
Feb 28, 2008
Messages
45
Hi there guys,

Im in a bit of a predicament, I have a main form with 3 subforms named:

  • Debit/Cred income for day subform
  • Cheque income for day subform
  • PDC income for day subform

and in each of these subforms, I have a field/text box (From a query) which is called "SumOfTotal Cost"

and also in the mainform I have another field/text box called "text73"

Now, all I wanted to simply do was to add all of those fields mentioned together to display them on the main form in another text box as a total so I tried to use this expression in the control source:

Code:
=Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]+Me![Cheque income for day subform].Form![SumOfTotal Cost]+Me![PDC income for day subform].Form![SumOfTotal Cost]

But when i open the form, the text box just appears saying

"#Name?"

I then tried to put brackets at the ends of the code, but still nothing would work, I then tried to access each individual "SumOfTotal Cost" by putting the following in a text box:

=Forms![Cheque Income For Day subform]![SumOfTotal Cost]

but it still comes up with "#Name?".

I am pretty annoyed and I would really appreciate it if someone could please help me

Thanks a lot
 
Plug this in 1 part at a time a see where it zonks:

First:

=Me!Text73

Then:

=Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]

etc...
 
Ok, ive found something

when i put me! it does not work at all, so eg:
=me![Text73]
does not work at all, and comes up with #NAME? error

but when I use
=[Text73]
it works fine

Im guessing its affecting the others in the same way, but i dont know how to fix it :(
 
I'm guessing you need to set/reset this in the main form OnCurrent event instead of in the default property of the control.
 
I don't know if this is what you are after, it is a copy from one of my forms/subform. Only involes two subforms but should be OK to change to more

=([SPPI]![Sum Insured])+([SPPI]![Reg Premium])+([SPP]![Text66])+([Forms]![MasterForm]![Text1527])

SPPI is one sub form and SPP is another subform and MasterForm the main form

The text box is on the mainform (MasterForm)
 
Last edited:
Sorry ken, how exactly would i set it to "onCurrent event" as i cant see the field in the "Events" tab

oh and i tried to test it out on "on Enter" but when I click on the box and it gets focus i get the error "the object doesnt contain the automation object 'Me'"

Code:
=Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]+Me![Cheque income for day subform].Form![SumOfTotal Cost]+Me![PDC income for day subform].Form![SumOfTotal Cost]

theres the code again
 
The OnCurrent is a form event and fires as you move from record to record...
 
Would i create the event by going to build event > expression builder then entering the following?:

=[onCurrent]=Me!Text73+Me![Debit/Cred income for day subform].[Form!SumOfTotal Cost]+Me![Cheque income for day subform].Form![SumOfTotal Cost]+Me![PDC income for day subform].Form![SumOfTotal Cost]
 
I don't know if this is what you are after, it is a copy from one of my forms/subform. Only involes two subforms but should be OK to change to more

=([SPPI]![Sum Insured])+([SPPI]![Reg Premium])+([SPP]![Text66])+([Forms]![MasterForm]![Text1527])

SPPI is one sub form and SPP is another subform and MasterForm the main form

The text box is on the mainform (MasterForm)

sorry mike, sadly its not working :( i just dont know why
 
No - :p

In the forms property window you should see the OnCurrent event. Put your code there.
 
haha, my mistake, only problem is, Ive entered the below code into it, but its coming up with the error "the object doesnt contain the automation object 'Me'"


=[Text86]=Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]+Me![Cheque income for day subform].Form![SumOfTotal Cost]+Me![PDC income for day subform].Form![SumOfTotal Cost]
 
Start from scratch again. Try the simplest one first, etc...

First:

me.Text86 = Me!Text73

Then:

me.Text86 = Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]
 
sorry mike, sadly its not working :( i just dont know why

Did you get the "#Name?"

I wonder what you have that is different as that works for me and is a copy/paste from my form.

Could you post up a compacted/Zip extract from your DB
 
yeah mike it did, again! lol

http://www.fileden.com/files/2007/1/29/710875/TheKingsHouse.zip

Theres the D/L link for the DB,the form in question is the "frm_income" form, the text box I am trying to use to put the calculated value in is near the bottom and is called "Text86" and has the label "Total Income" next to it. The subforms are the 3 really squashed ones underneath the titles and ermm yeah, you can move stuff around to get a better idea and stuff, each of the three subforms have their own queries as well.
 
Last edited:
Start from scratch again. Try the simplest one first, etc...

First:

me.Text86 = Me!Text73

Then:

me.Text86 = Me!Text73+Me![Debit/Cred income for day subform].Form![SumOfTotal Cost]

I entered:

Me.Text86 = Me!Text73

but it now just comes up with an error saying "Microsoft office cant find the macro 'Me'.

I also tried:

Me!Text86 = Me!Text73

but it says "Microsoft office cant find the macro 'Me!Text86 = Me!Text73'.

I then tried:

Text86 = Text73

but it says "Microsoft office cant find the macro 'Text86 = Text73'.
 
I have just looked it at and my way will not work. I also tried just including the subforms in the calculatipn. Also tried Text34 instead of Text73

I also tried put " " around the form names.

Also tried a simple one =([Debit/Cred income for day subform]![SumOfTotal Cost]) and that also gave Name#. However if renamed the form (in the main form itself) then that worked.

But if rename the 3 subforms I can't get it to hold the brackets. After I save it goes from =([DebitCreditincomefordaysubform]![SumOfTotal Cost])+([ChequeIncomeForDaysubform]![SumOfTotal Cost])+([PDCIncomeforDaysubform]![SumOfTotal Cost])

to =(DebitCreditincomefordaysubform![SumOfTotal Cost])+(ChequeIncomeForDaysubform![SumOfTotal Cost])+(PDCIncomeforDaysubform![SumOfTotal Cost])

I will have more of play later as 8am Thursday here.
 
This worked on two of the subforms and Text73

=(DebitCredincomefordaysubform![SumOfTotal Cost])+(PDCIncomeforDaysubform![SumOfTotal Cost])+(Forms![frm_Income Form]!Text73)

Actually I had [] on Text73 but again it does not hold it.

Notice the subforms have been ranamed
 
You're not putting the code I posted in vba, you're simply putting it in the properties dialog window. You need to open the vba editor and put it in a code module.
 
just wondering why use"Me!" instead of "Me."

maybe, u can try to unlink and relink your reference library.
sometimes, problem comes from the virtual dead link meaning the library is ticked, however, due to whatever reason the linkage is broken or damaged.
 
just wondering why use"Me!" instead of "Me."

maybe, u can try to unlink and relink your reference library.
sometimes, problem comes from the virtual dead link meaning the library is ticked, however, due to whatever reason the linkage is broken or damaged.
ME. can refer to a property or a data box
Me! only refers to a data box

This helps to disambiguate what is meant if data boxes have names which clash with properties.
 

Users who are viewing this thread

Back
Top Bottom