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

Check for Value in Before Update Event

Status
Not open for further replies.

soupisgood84

Technical User
Apr 17, 2007
45
US
Can someone tell me why my code doesn't work? There are no errors (other then it not working). Please Help!

Code:
Private Sub RequisitionPrice_BeforeUpdate(Cancel As Integer)
       If Me.RequisitionPrice = "$0.00" Then
              'Message box warning
        MsgBox "Warning  " _
             & RequisitionPrice & " is not a valid entry." _
             & vbCr & vbCr & "You will now been taken to the record to correct tis problem.", _
               vbInformation, "Warning"
        Cancel = True
        End If
End Sub
 
I'd say that the problem is here:

[tt]If Me.RequisitionPrice = "$0.00"[/tt]

Currency is a format, the value would be zero.

[tt]If Me.RequisitionPrice = 0[/tt]
 
I thought that too, but the immediate window says that they are equal....plus I tried it both ways.
 
Is this textbox bound? Why not add a debug.print of the value?

If you type:
?"$0.00"=0
Into the immediate window, you will get a type mismatch error.
 
The default value set by Access was 0, because the type was set to Currency. But even then when I actually use 0 instead of "$0.00" the IF statement should work right?
Have I done something wrong in the statement?

Remou....
Really? I typed the same thing in my immediate window and it came back "True
 
If you use 0 instead of "$0.00" the IF statement should work, yes.

What version of Access are you using? I checked with Access 2000 and Access 2007 and if you include the quotes, you will get a type mismatch error.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top