If...then commands

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
 
K

Ken Snell \(MVP\)

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
 
F

fredg

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
 
K

Klatuu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top