Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Text Box to work as a Calculator

Status
Not open for further replies.

ottograham

Technical User
Mar 30, 2001
109
US
I have a table for Insurance Claims and fields for dollar amounts. I often have to sum many payments to get the total paid before entering.

I want to use the Before Update method to test the input: if it starts with "=", then execute the string and enter the number in the field (e.g "= 2111 + 333+ 4444").

What is the code to execute the string?

Thank you in advance for your help.
 
Steve:

That works... thanks

I'm getting an error that its an invalid field type

The code follows: What am I doing wrong.

Thanks!

Private Sub Paid_BeforeUpdate(Cancel As Integer)

Dim str As String
Dim ans As Single

str = Me.Paid
If "=" = Left(str, 1) Then
ans = Eval(Mid(str, 2))
Me.Paid = ans
Else
End If
End Sub
 
Private Sub Command1_Click()
Dim str As String
Dim ans As Single
str = Me.paid
If "=" = Left(str, 1) Then
ans = Eval(Mid(str, 2))
Me.paid = ans
Else
End If
End Sub

seems to work on 4 me. I created a form with a paid text box. Steve Medvid
"IT Consultant & Web Master"
 
Steve:

I simplified it and used an inputbox and double click. It works great. The EVAL() was what I needed. Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top