inputbox cancel error 13

supmktg

Registered User.
Local time
Today, 12:22
Joined
Mar 25, 2002
Messages
360
I'm trying to trap the error 13 that occurs when the cancel button on my inputbox is clicked. I have tried several recommended methods, but none seems to work.

This is the most recommended code:
Code:
Private Sub chkPaid_AfterUpdate()
Dim intAmtPd As double
intAmtPd = Round(InputBox("Please enter the amount paid for this procedure " & Me.Description, "Amount Paid"), 2)
    If intAmtPd ="" Then
    Exit Sub
    End If
blah
blah
blah
End Sub

I've also tried:
If intAmtPd <.01 Then
Exit Sub
End If

and

If strptr (intAmtPd) = 0 Then
Exit Sub
End If

Nothing works.What am I doing wrong?

Thanks,
Sup
 
Last edited:
Clicking cancel will result in a zero length string (""), so test for that.
 
That's the first thing that I tried but it doesn't work.

I'm thinking that the problem is that I declared 'intAmtPd' As double and not As string. I guess that I can change it to string and then convert it to double after I get past the cancel button.

Should there be a way to check for cancel with a number?

Thanks,
Sup
 
You can check the length of what was entered, or use IsNumeric. As you suspect, you can't put a ZLS into a variable declared as a Double. You can switch that to variant, which will accept anything.
 

Users who are viewing this thread

Back
Top Bottom