By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

MS Access - Executing a statement

P: 1

I have a large calculation along the lines

Forms!A_Main!price + Forms!A_Main!Oprtions etc etc
that I would like as a variable so I only have to execute the variable when I need it, with out having to retype it. This cacluation is used on both forms and reports.

Any help would be greatly appreciated.

Dec 5 '07 #1
Share this Question
Share on Google+
1 Reply

P: 30
I would probably try creating a function in a code module to return the value from the calculation. This could then be used on forms, reports and also in a query.

Expand|Select|Wrap|Line Numbers
  1. Public Function fMyFormCalc() As Long
  3. fMyFormCalc = Forms!A_Main!price + Forms!A_Main!Oprtions
  5. End Function
If all the field are on the form Forms!A_Main, your could also add a text box that does the calculation, then reference the text box's value as needed. The control could also be hidden is you do not want the user to see it.
Dec 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.