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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript not working

Status
Not open for further replies.

slyscurry

Programmer
Aug 7, 2008
5
0
0
US
Hello,
I have a form with two numbers that I compare when a button is clicked. If they are not equal then a text box will pop up, but occasionally a text box pops up even though the numbers equal. Below is the script...

If Me.FormTotal <> Me.TxnAmount Then
MsgBox "Line Items must total to transaction amount!"
Me.AcctgTxnAmt.SetFocus
Cancel = True
Exit Sub
End If

Thanks!
 
Double and Single are only approximations.
I'd use the following:
If CDec(Me!FormTotal) <> CDec(Me!TxnAmount) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This looks like VBA rather than VBScript. You may need to move the focus or recal the form before checking if the controls are equal, depending on how you have set it up.
 
you're probably right about the VBA, I'm very unfamiliar with visual basic. I tried the CDec() method and that worked.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top