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

Prevent Null Value 1

Status
Not open for further replies.

LouieGrandie

Technical User
Mar 3, 2011
136
US
Have a form in which a number of fields are summed in another field. Works fine. However if someone accidentally deletes the value from one of the fields the sum field also goes blank. I am trying to wrote code after update so that if the value of a field is deleted the field defaults to zero (0). Here is what I am trying but it is not working.

Private Sub RevisionsActualTimeRequired_AfterUpdate()
If Me.RevisionsActualTimeRequired.Value = "" Then Me.RevisionsActualTimeRequired.Value = 0
End Sub


Any suggestions.

Visit Sage's Online Community
 
Null is not the same as "". Try:
Code:
Private Sub RevisionsActualTimeRequired_AfterUpdate()
    If IsNull(Me.RevisionsActualTimeRequired) Then 
        Me.RevisionsActualTimeRequired = 0
    End If
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Or, to check for both Nulls and Zero-Length Strings ("")

Code:
Private Sub RevisionsActualTimeRequired_AfterUpdate()
 If Nz(Me.RevisionsActualTimeRequired, "") = "" Then
    Me.RevisionsActualTimeRequired = 0
 End If
End Sub
Linq ;0)>


The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
My version of this:
If Nz(Me.RevisionsActualTimeRequired, "") = "" Then
is this:
If Trim(Me!RevisionsActualTimeRequired & "") = "" Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top