MS Access 2013

deefel
deefel used Ask the Experts™
on
My form has a text box that has an expression in it.  The expression is called expName3.  I need the value of that expression to populate into a table ~ in a field labeled NametoUse.  Is it possible to take the value from an expression on a form and have it populate into a table.  
Example Expression on my form:  If there is a value in the Name field on Form C then give me the Name else it blank leave blank.  Whenever the user types a different name the value in the expression will change.  I then need to capture  the value displayed in the expression and have it populate into a table.  Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Top Expert 2014

Commented:
You can, but it's not really clear what you're doing.

Assuming your "example expression" is similar to your real one, then what's the point of storing the value from "Name" in another field? You've already got that value (in the Name column, presumably) so what's the point in storing it again?
Will be better if you upload sample DB with this form. related tables and some dummy data.
There is some difference in editing of existing data and entering new one. For new one set default value for table's field to your form's field. If you like to edit existing data and take value from unbounded field, you will need VBA code

Author

Commented:
~ I attached a sample database.  The field in yellow on the form is the value I would like to capture in the table.  Currently it is only displayed on the form.  Thanks for your help.
TestDatabase.accdb
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

What field in table should be filled? Do you like to fill it in existing records?

Author

Commented:
The ESTPrice field should be filled in the table with the value in the yellow box on the form (ESP_Price).  thanks
Look at sample. Press button for filling. You can add code from button to any action on your form (some field update, etc.)
TestDatabase.accdb
Most Valuable Expert 2012
Top Expert 2014
Commented:
I would encourage you to rethink doing this. In a relational database you should never store calculated data unless you're archiving that data (i.e. you'll never edit it again, and it's only for historical/reporting needs).

Access is not Excel, and should not be used like Excel. Multiple IIF statements, like you're using here, almost always indicate a poorly designed table structure. Issues like this are fairly easy to fix, as als has shown you, but as you move forward you'll find more and more obstacles (and when you get to the reporting phase, you'll find some that are nearly insurmountable).

Take time now, when you're just beginning to create your database, and build it correctly. It'll take more time now, but you will reap the benefits of a properly created database many times over as your application grows more complex.
Sometimes you need to save current price to document, because it could be changed later, but it is also obvious that calculated fields should not be saved without necessity.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial