Solved

Simple Calculator for Access Form

Posted on 2004-09-24
6
447 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

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…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

815 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

11 Experts available now in Live!

Get 1:1 Help Now