Link to home
Start Free TrialLog in
Avatar of Cal Guy
Cal GuyFlag for United States of America

asked on

Simple Calculator for Access Form

Is there a way to add a very simple calculator to an Access form?  I don't need one with memory, or anything fancy, just simple addition, subtraction, multiplication, and division.  Thank you for your help.
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Create a textbox on your form and put a button on the form that has this code:

Msgbox Eval(Me!MyTextBox)

The user can now type in something like:
2*3+5

into the textbox, and clicking on the button will give a message box with the result.
Avatar of Cal Guy

ASKER

Thanks for the suggestion, but I'm looking for a graphical one.  Something where a user could use the mouse and click on the buttons.  Sort of like the one that is in Windows.

CalGuy
Avatar of Steve Bink
Then place a command button on your form.  For the OnClick event, have it load and run the Windows calculator.  The default installation location for the program is: "%SystemRoot%\System32\calc.exe"

Otherwise, you will have to create a separate form, program all the buttons, logic, etc.  It is a fairly straight-forward project, but it can be very time consuming (especially if you consider operator precedence).  Best to use what is already made available to you.
Avatar of Cal Guy

ASKER

routinet,

True it may be time consuming, but I think, no I know that the person who uses the database would need the simplicity of having a built in calculator.  Something that could be added to the form.  I saw a download of a calculator built in Access but was unable to incorporate it into my database.  I know that it's a lot of programming and I think I have a handle on it but my main problem was how to have the textbox space over once a second number button was pressed.  I had it to where it would enter the correct number in the textbox when pressed, but as soon as another button is pressed it erased the first and replaced with the new number.  I'm currently using somthing like this:

Button 8 Code:

Me.calcwindow = "8"

Now I know that when the button is pressed with this code, it commands the "calcwindow" textbox to reflect the number 8.  My main problem is, how do I have it accumulate the numbers until I can get to the "+""-""/""X" buttons?
ASKER CERTIFIED SOLUTION
Avatar of shanesuebsahakarn
shanesuebsahakarn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cal Guy

ASKER

This is what I was looking for.  It totally slipped my mind!!  I couldn't get the numbers to accumulate in the window and forgot about the "&" symbol....DUHHH!!!!

Thank you!

CalGuy