Completing formula in text box (1 Viewer)

Gavx

Registered User.
Local time
Tomorrow, 02:08
Joined
Mar 8, 2014
Messages
151
Is there any way I can configure a text box so that I can enter a formula in it and the result can be displayed/written?

For example say I want to put in the text box 179+11 and want the result to display as well as being written to the db. Sort of like an excel cell.

thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:08
Joined
May 7, 2009
Messages
19,237
use Eval(textbixName)
 

Gavx

Registered User.
Local time
Tomorrow, 02:08
Joined
Mar 8, 2014
Messages
151
And how would I use this statement?
 

missinglinq

AWF VIP
Local time
Today, 12:08
Joined
Jun 20, 2003
Messages
6,423
The problem is going to be the 'being written to the db' part.

Access is not going to let you enter 179+11 into a Control that is Bound to a Field that is defined as a Number...the Field would have to be defined as Text.

You could then use

Code:
Private Sub txtName_AfterUpdate()
  Me.txtName = Eval(Me.txtName)
End Sub

as arnelgp suggested.

This would be fine if you never have to use this 'Number' for any calculations, elsewhere in the database. If you do, you'd have to Convert the Text to a Number, using one of the Type Conversion Functions, such as CInt(expression) or
CDbl(expression).

Linq ;0)>
 

Users who are viewing this thread

Top Bottom