Having trouble validating a txt box based on the value of a cbo box. See the code below.
Private Sub Form_AfterUpdate()
If Me.cboSST.Value = "hello" And IsNull(Me.txtSSP.Value) = True Then
DoCmd.CancelEvent
MsgBox "You can't have SSP be null while SST is the value hello"
DoCmd.GoToControl "txtSprinklerSystemPct"
End If
End Sub
I'm trying to not let the form move to the next record if cboSST has the value "hello" in it, and force the focus back to txtSSP. It works the first time, (i.e. you get the message box, and the focus goes to txtSSP and the form doesn't proceed to the next record) but then you can just click the next record button again and it goes through, just like the validation was never there to begin with. What am I missing? am I using the wrong form event? I tried the Refresh method but it doesn't work - Can someone point me in the right direction? I'm using access 2002.
Thank you How much more water would there be in the ocean if it weren't for sponges?
Private Sub Form_AfterUpdate()
If Me.cboSST.Value = "hello" And IsNull(Me.txtSSP.Value) = True Then
DoCmd.CancelEvent
MsgBox "You can't have SSP be null while SST is the value hello"
DoCmd.GoToControl "txtSprinklerSystemPct"
End If
End Sub
I'm trying to not let the form move to the next record if cboSST has the value "hello" in it, and force the focus back to txtSSP. It works the first time, (i.e. you get the message box, and the focus goes to txtSSP and the form doesn't proceed to the next record) but then you can just click the next record button again and it goes through, just like the validation was never there to begin with. What am I missing? am I using the wrong form event? I tried the Refresh method but it doesn't work - Can someone point me in the right direction? I'm using access 2002.
Thank you How much more water would there be in the ocean if it weren't for sponges?