If...then commands

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

I have some code and what i want it to do is not allow the procedure to
proceed if the value is -1, otherwise it can proceed.

I have attached what i want to do, can someone point me what i need to do

Private Sub JobnumbersID_Exit(Cancel As Integer)
If Me.work_completed = -1 Or Me.work_invoiced = -1 Then ??????
End If
End Sub
 
Private Sub JobnumbersID_Exit(Cancel As Integer)
If Me.work_completed <> -1 And Me.work_invoiced <> -1 Then
' put the code here that defines the "process"
End If
End Sub
 
I have some code and what i want it to do is not allow the procedure to
proceed if the value is -1, otherwise it can proceed.

I have attached what i want to do, can someone point me what i need to do

Private Sub JobnumbersID_Exit(Cancel As Integer)
If Me.work_completed = -1 Or Me.work_invoiced = -1 Then ??????
End If
End Sub

If Me.work_completed = -1 Or Me.work_invoiced = -1 Then
Exit Sub
Else
' Do something else here.
End If

Even easier, you can use:

If Me.work_completed = -1 Or Me.work_invoiced = -1 Then
Else
' Do something here.
End If
 
If what your are doing is validating the value of a bound control, the code
should actually be in the Before Update event. By the time you get to the
Exit event, the value has already been updated:
Private Sub JobnumbersID_BeforeUpdate(Cancel As Integer)
With Me
If .work_completed Or .work_invoiced Then
MsgBox "Invalid Entry"
Cancel = True
End If
End With
End Sub
 
Back
Top