PC Review


Reply
Thread Tools Rate Thread

Can I run formulas from a text field?

 
 
Marc H
Guest
Posts: n/a
 
      16th Oct 2008
I need to calculate a dollar amount for differently in each line of a table.
I have a [CalcMethod] field and currently use a SELECT CASE structure to do
the calculation depending on the value in [CalcMethod] and place the value in
[Total]. ex. In row 1 of the table the calculation is [Total] = [Volume] *
[Price]. In row 2 the calculation is [Total] = [Volume] * [Units] *
[UnitPrice]. In row 3 the calc is [Total] = [Volume] * [Charge] *
[PercentofCharge]. These formulas are hardcoded into the SELECT CASE
structure.

I would like to have a table with id and text fields with these formulas
loaded in the text field, then find the formula using the id and run it. This
would allow me to add new formulas on the fly. Can I do this?
 
Reply With Quote
 
 
 
 
Klatuu
Guest
Posts: n/a
 
      16th Oct 2008
Look in VBA for the Eval function. It is used to convert a string to an
expression and execute it. For example:

strExpr = "5 * 25"

x = Eval(strExpr)
x will now = 125

"Marc H" <(E-Mail Removed)> wrote in message
news:00C8CAA3-8F89-4B0D-9F60-(E-Mail Removed)...
>I need to calculate a dollar amount for differently in each line of a
>table.
> I have a [CalcMethod] field and currently use a SELECT CASE structure to
> do
> the calculation depending on the value in [CalcMethod] and place the value
> in
> [Total]. ex. In row 1 of the table the calculation is [Total] = [Volume] *
> [Price]. In row 2 the calculation is [Total] = [Volume] * [Units] *
> [UnitPrice]. In row 3 the calc is [Total] = [Volume] * [Charge] *
> [PercentofCharge]. These formulas are hardcoded into the SELECT CASE
> structure.
>
> I would like to have a table with id and text fields with these formulas
> loaded in the text field, then find the formula using the id and run it.
> This
> would allow me to add new formulas on the fly. Can I do this?



 
Reply With Quote
 
Marc H
Guest
Posts: n/a
 
      17th Oct 2008
So simple! Thanks.

"Klatuu" wrote:

> Look in VBA for the Eval function. It is used to convert a string to an
> expression and execute it. For example:
>
> strExpr = "5 * 25"
>
> x = Eval(strExpr)
> x will now = 125
>
> "Marc H" <(E-Mail Removed)> wrote in message
> news:00C8CAA3-8F89-4B0D-9F60-(E-Mail Removed)...
> >I need to calculate a dollar amount for differently in each line of a
> >table.
> > I have a [CalcMethod] field and currently use a SELECT CASE structure to
> > do
> > the calculation depending on the value in [CalcMethod] and place the value
> > in
> > [Total]. ex. In row 1 of the table the calculation is [Total] = [Volume] *
> > [Price]. In row 2 the calculation is [Total] = [Volume] * [Units] *
> > [UnitPrice]. In row 3 the calc is [Total] = [Volume] * [Charge] *
> > [PercentofCharge]. These formulas are hardcoded into the SELECT CASE
> > structure.
> >
> > I would like to have a table with id and text fields with these formulas
> > loaded in the text field, then find the formula using the id and run it.
> > This
> > would allow me to add new formulas on the fly. Can I do this?

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Name a text field containing formulas 9568dc Microsoft Access 3 7th Jan 2010 09:49 PM
Writing text from a combined text field to a table text field pdlginternet@aol.com Microsoft Access Forms 1 8th Nov 2007 10:18 PM
Copying text field to another text field on a single form =?Utf-8?B?Um9uYWxkX0w=?= Microsoft Access 0 22nd Aug 2006 04:58 PM
primary text field checking for dupes after text field is updated =?Utf-8?B?U3VnYWRh?= Microsoft Access Form Coding 4 25th Mar 2005 07:11 PM
HELP!! Populate text in single XL field, or bulk copy text into 1 field filmfatale Microsoft Excel Programming 0 9th Dec 2003 02:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:02 AM.