CALCULATOR

  • Thread starter Thread starter Antonio CC via AccessMonster.com
  • Start date Start date
A

Antonio CC via AccessMonster.com

Hi,
I need to create a very simple calculator that opens on a KeyPress event, and
that "imports" the current value of a field.
After I calculate upon it, I need to send back the result to the same field.

Anyone?
Thanks
A
 
Assuming the value is an int, this should work, obviously substitute
variables names for your own:
Private sub Key_Press.click()
dim tempstore as integer
tempstore = [forms]![form_name]![field]
tempstore = calculate(tempstore) ----- <whatever your calculation thing is here>
[forms]![form_name]![field] = tempstore
end sub


This is a simplistic solution, but should cover for most things... this is
from memory so check my syntax.
 
Matt, thanks for your post.
The problem with it is that, when my Calculator ir triggered on a certain Key
Press event, the value in [forms]![form_name]![field] is not yet saved.
Suppose that you have a field with "0" and I want to activate the Calculator
whenever I press "=", "*", "+", "-" or "/". Suppose that I type "1000*". The
calculator should "import" the value 1000.
Do you know any way to save the typed value, even before "exiting" tje field?

Thanks
Antonio

Matt said:
Assuming the value is an int, this should work, obviously substitute
variables names for your own:
Private sub Key_Press.click()
dim tempstore as integer
tempstore = [forms]![form_name]![field]
tempstore = calculate(tempstore) ----- <whatever your calculation thing is here>
[forms]![form_name]![field] = tempstore
end sub

This is a simplistic solution, but should cover for most things... this is
from memory so check my syntax.
 
If you have an after_update on the text field storing the value, with a sub:

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70

this will save the record every time the value in the field is changed.

If the form (or field on the form) isn't bound to a table, then obviously
there is nothing to save the value to. you could try a line of code in the
after_update that stores the value to a global variable perhaps?

Antonio said:
Matt, thanks for your post.
The problem with it is that, when my Calculator ir triggered on a certain Key
Press event, the value in [forms]![form_name]![field] is not yet saved.
Suppose that you have a field with "0" and I want to activate the Calculator
whenever I press "=", "*", "+", "-" or "/". Suppose that I type "1000*". The
calculator should "import" the value 1000.
Do you know any way to save the typed value, even before "exiting" tje field?

Thanks
Antonio
Assuming the value is an int, this should work, obviously substitute
variables names for your own:
[quoted text clipped - 8 lines]
This is a simplistic solution, but should cover for most things... this is
from memory so check my syntax.
 
Antonio

If you are still looking for a simple 4 function Popup Calculator that can
be bound to a control on your form, you may want to look here:
http://www.worksrite.com and click on the News link.

This is a 100% Access solution that can easily be integrated into your
project by importing just 1 form and 1 module. Once this is done you have
only to make a simple call to a function in the module from the event you
want to launch the Calculator from.

Ron W
 
Back
Top