Forms/Sub-forms

Cori

Registered User.
Local time
Today, 10:11
Joined
Oct 6, 2006
Messages
53
I need to take a number from a catagory in a sub form and add it to a number in a form to give me a total. I have the text box set up and it gives me the total from the main form, but it wont incorporate the number from the sub-form into the total. is there some specific verbage i need to use to make this happen??? and what would that be if the answer is yes???
 
The syntax to refer to a control on a subform is:
Code:
Forms!YourMainFormNameHere.YourSubFormControlNameHere.Form.Control

So, if I have a form named 'frmMain' and a subform control named 'sfrmMain' and a text box on the subform named 'txtTotal' and I wanted to add that value to a text box on my main form along with a value from 'txtMainTotal' I would write (if the code is on the main form):
Code:
Me.txtGrandTotal = Forms!frmMain.sfrmMain.Form.txtTotal + Me.txtMainTotal
 
In the Me.txtGrandTotal= do i have to have the me. or is that just the name of your text box?
 
Me. is the way you can refer to the current form (a coding shortcut). You don't have to use it, but it enables you to use the intellisense feature in the coding window to quickly code. If you prefer, you can use the full name of your form (Forms!YourFormName) which would replace (Me).
 
Sorry, but is the second form in the code really the word form or is it the name of the form. "Forms!frmMain.sfrmMain.Form.txtTotal"
 
You have to use the word 'FORM' there. It isn't a name of a form, but telling Access something.
 
This is what i have and it is showing #Name? in the text box. Maybe this will help me/you better :)

Me.DailyTotal=Forms!frmEditTime.frmProjects.Form.SubTotal+Me.MainTotal
 
Okay, is frmProjects the name of the subform, or the subform control? The subform control is what houses the subform on your main form and, while it can be the same name as the subform, it may not be.
 
Yes frmProjects is the sub-form...and it looks like frmProjects is also the name of the subform control... (that is if you highlight the subform and the name and the source object are the same).
 
If any of your controls that you are referencing for the calculation have the same name as the fields that they are bound to, then you will need to change the control name. So, if your field is 'Amount' and your control's name is 'Amount' (the default that Microsoft uses when the wizard creates the form), you should change the control name to something like txtAmount.
 
Ok i have changed those things and it now looks like this:
Me.txtDailyTotal=Forms!frmEditTime.sfrmProjects.Form.txtHours+Me.txtDailyTotal

It is still not working though...sorry for being a pain
 
Can you zip a copy of the database so I can look at it? If you compact it and then zip it, it must be under 393kb to be able to post here. Let me know if you need to know how to post attachments here.
 
I can't get it under 520kb is there another way
 
How big is it? If it isn't too big, you might be able to email it to me at

accessguru at hotmail dot c0m
 
I emailed it, but you probably wont be able to open it...that is my experiance with access files anyway.
 
You have to zip it and not send it directly as an MDB file. You can also try changing the extension to something like .mdg, but zipping it is more likely going to be able to work.
 
Changing the control source of the Daily total to this will work for displaying it, but after looking at your database I'm concerned that the way you've designed this is going to cause you headaches. I don't have time right now to give you a rundown on the issues I see, but I'll try to do it later.

For now, to display the total in that text box, this should work:
Code:
=Forms!frmEditTime.sfrmProjects.Form.txtHours.Value+[Vacation]+[Sick]+[Holiday]+[TimeOff]+[GeneralAdmin]+[Meetings]+[Training]+[QASupport]+[ProdSupport]+[PurchSupport]+[ServSupport]+[PartSupport]+[SaleSupport]+[LitigSupport]+[EngSupport]+[ECRProcessing]+[Misc]
 
I already know what you mean about the headaches since i have no idea what i am doing. Thanks for your help. My database is a work in progress since this is all new to me and i am pretty much self taught. Any help would be greatly appreciated. Have a great day.
 
Last edited:
I know i have bugged you a bunch already and you have helped me soo much :) I was hoping that you could help me with a similar string for a report and a sub-report. Any direction you can turn me would be benificial. thank you so much agian for your help :)
 

Users who are viewing this thread

Back
Top Bottom