Solved

Simple Calculator for Access Form

Posted on 2004-09-24
6
398 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
ID: 12146638
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
ID: 12146661
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
ID: 12146725
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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 

Author Comment

by:calguy
ID: 12146794
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
ID: 12146831
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
ID: 12146885
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

932 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

12 Experts available now in Live!

Get 1:1 Help Now