Solved

Simple Calculator for Access Form

Posted on 2004-09-24
6
369 Views
Last Modified: 2006-11-17
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.
0
Comment
Question by:calguy
  • 3
  • 2
6 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
Comment Utility
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.
0
 

Author Comment

by:calguy
Comment Utility
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
0
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
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.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:calguy
Comment Utility
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?
0
 
LVL 41

Accepted Solution

by:
shanesuebsahakarn earned 300 total points
Comment Utility
Just use something similar to the method I suggested. That is:
Me.calcwindow=Me.calcwindow & "8"

As the user clicks the buttons, the textbox will show the whole expression, that is:
10+11+7*4

The "=" button can then just do this:
Me.calcwindow=Eval(Me.calcwindow)
0
 

Author Comment

by:calguy
Comment Utility
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
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now