stuck on validation

teiben

Registered User.
Local time
Today, 22:12
Joined
Jun 20, 2002
Messages
462
How do I write this, I do know the code needs to go on the before update of the form

If a quanity is entered then defect_descripion must contain something.
I've tried:

If quanity <=0 then
defect_descripion not null or defect_descripion =""
msgbox "you must select a defect descripion"



I have the this part of the code

me.defect descripion.setfocus
cancel = true
end if
end sub

please help I'm at my wits end
 
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Me.Quanity > 0 And IsNull(Me.defect_descripion) Then
        Cancel = True
            MsgBox "You must enter both Quanity and Defect Desciption"
            Me.defect_descripion.SetFocus
    End If

End Sub

You had:
Code:
If quanity <=0
Which mean if it is equal to or less than 0

You stated:
If a quanity is entered then defect_descripion must contain something
Which I took to mean, if the quanity is greater than 0 then defect_description must contain data.
The above code of mine will do that, but won't stop something being entered into defect_description and leaving quanity blank. You will have to write some code to check for that. My code should give you some ideas.

Any problems post back.
 
worked like a charm - thanks
 

Users who are viewing this thread

Back
Top Bottom