Results 1 to 4 of 4
  1. #1
    itm is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    69

    Question Trying to find away to display the value of a calculation

    Hi,


    I am trying to find away to allow the user to put a calculation in a textbox,like you can in an Excel cell, and have it return the value in another textbox.For example, the user types in the one box "2*20/4" and put the value(10) in another box.
    So far I have not been able to do this; any ideas would be really appreciated.
    Thank you
    itm

    here is my code and I have tried many things, but here is my latest try:


    Code:
    txtDollarImpact.Text = CStr(Val(txtCalcs.Text))

  2. #2
    John_G is offline VIP
    Windows XP Access 2003
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    You want to use the eval function - for example eval("2*20/4") yields 10.

    Try this for yours: txtDollarImpact.Text = Eval(txtCalcs.Text)

    HTH

    John

  3. #3
    itm is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    69
    Thanks that worked.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,545
    Keep operator precedence in mind.
    1+8*2 = 17
    (1+8)*2=18
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 05-28-2012, 06:44 PM
  2. Find employee, display name, calculate retirement
    By sephiroth2906 in forum Forms
    Replies: 2
    Last Post: 10-24-2011, 02:59 PM
  3. Calculation
    By Maggie in forum General Chat
    Replies: 2
    Last Post: 10-16-2011, 12:49 PM
  4. Replies: 5
    Last Post: 03-03-2011, 03:56 PM
  5. Report control of a field display/no display
    By systems013 in forum Reports
    Replies: 5
    Last Post: 02-01-2010, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums