Text Box as calculator

  • Thread starter Haggr via AccessMonster.com
  • Start date
J

Jeff Boyce

I don't see any question marks. Is there a question in this?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
H

Haggr via AccessMonster.com

sorry, thinking about programming while typing.
Is there a way to make a Text Box act as a calculator. Meaning while text
box has focus you could enter 8 + 2 and have the data entry be 10?
 
J

John Vinson

8 + 2 10

My accounting program does this

<shrug>

Access isn't an accounting program. It's a database.

You can write VBA code using the Eval() function to do this, but it
would be somewhat complex. What are you trying to accomplish? What's
the context?

John W. Vinson[MVP]
 
H

Haggr via AccessMonster.com

I have a data enrty form. One text box requires the user to do math before
entering data. One user is as dumb as a box of rocks, but she looks good.
(kidding) I would like to be able to use that text box to do math before
entering data. Thanks
 
J

John Vinson

I have a data enrty form. One text box requires the user to do math before
entering data. One user is as dumb as a box of rocks, but she looks good.
(kidding) I would like to be able to use that text box to do math before
entering data. Thanks

I think you would need to use TWO textboxes: an unbound one for
typing, and a second control bound to the table field. In the
AfterUpdate event of the unbound textbox you could use:

Private Sub txtUnbound_AfterUpdate()
Me!txtBound = Eval(Me.txtUnbound)
End Sub


However, this will need error checking (in case the user enters some
un-evaluable expression); you'll also want code in the form's Current
event to copy the actual table value into the unbound textbox.

John W. Vinson[MVP]
 
Top