Solved

Trying to write value of a calculated field on a subform to a field in a table

Posted on 2013-06-17
5
278 Views
Last Modified: 2013-06-18
I have a form bound to a table.  On the form is a subform with a calculated field.  For now the field is named Text59.  When the main form closed I have this code in the onclose event but it isn't working.  I get a message that says it can't find the subform.

????


Here's the code:

CurrentDb.Execute "Update  tblProjectBudgetHeader set ConstructionBudget = " & Forms!subfrmProjectBudgetDetails.Text59 & " Where ID=" & Me.Combo113.Column(0), dbFailOnError
0
Comment
Question by:SteveL13
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 85
ID: 39254658
You refer to a Subform like this:

Forms!NameOfTheParentForm.NameOfTheSubformCONTROL.Form.YourControl

Note "NameOfTheSubformCONTROL" - this is the name of the CONTROL on the Parent form, and may or may not be named the same as the form you're using as a Subform.
0
 

Author Comment

by:SteveL13
ID: 39254675
I must have this totally messed up.

CurrentDb.Execute "Update  tblProjectBudgetHeader set ConstructionBudget = " & Forms!frmProjectBudget.Text59.subfrmProjectBudgetDetails.Me.Combo113.Column(0) & " Where ID=" & Me.Combo113.Column(0), dbFailOnError
0
 
LVL 85
ID: 39254679
Is "Text59" the name of the control that holds the calculated data?

If so then perhaps this:

CurrentDb.Execute "Update  tblProjectBudgetHeader set ConstructionBudget = " & Forms!frmProjectBudget.subfrmProjectBudgetDetails.Text59 & " Where ID=" & Me.Combo113.Column(0), dbFailOnError

And remember that it's typically NOT a good idea to store calculated data in a field. If you have a formula to calculate the value, then you should use that formula each time you need to work with the data. This recreates the data from the source, so if the source changes, you don't have to worry with updating the ConstructionBudget each time.
0
 

Author Comment

by:SteveL13
ID: 39254697
This doesn't work either:

CurrentDb.Execute "Update  tblProjectBudgetHeader set ConstructionBudget = " & Forms!frmProjectBudget.subfrmProjectBudgetDetails.Text59 & " Where ID=" & Me.Combo113.Column(0), dbFailOnError

Here is the latest (note that I changed ID to BudgetID which is the name of the field).
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39254949
Oops ... forgot the Form call:

Forms!frmProjectBudget.subfrmProjectBudgetDetails.Form.Text59
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question