Code help with IsNot( ) operator

S

Sunflower

I have an event procedure on the exit of my sub form

CODE:
____________________
Private Sub LABORDETAIL_Exit(Cancel As Integer)
If Me.NULLSUM = 0 And Me.Status = "OPEN" Then

MsgBox "HEY!!!! YOU NEED TO CHANGE THE STATUS TO - COMPLETED!!"

End If

Me.Status.SetFocus
End Sub
_____________________

Works great when the status is "OPEN"

When make the following change to the second line of code...

If Me.NULLSUM = 0 And Me.Status = "OPEN" Or "Out On Proof" Or "At
Printer/Production" Or "On Hold" Or "Waiting on Someone Else" Then



I breaks!!!


I have also tried...

If Me.NULLSUM = 0 And Me.Status = IsNot("Completed") Then


What am I missing?
 
B

Bob Quintal

m:
I have an event procedure on the exit of my sub form

When make the following change to the second line of code...

If Me.NULLSUM = 0 And Me.Status = "OPEN" Or "Out On Proof" Or
"At
Printer/Production" Or "On Hold" Or "Waiting on Someone Else" Then



I breaks!!!

What am I missing?
you are missing Me.Status = after each OR, and possibly also some
parentheses

If Me.NULLSUM = 0 And _
(Me.Status = "OPEN" _
Or Me.Status ="Out On Proof" _
Or Me.Status = "At Printer/Production" _
Or Me.Status = "On Hold" _
Or Me.Status = "Waiting on Someone Else") Then

You should think about moving all the status texts to a new 2 field
table StatusID and StatusText and changing Status to a number. Use a
combobox to show the text.That way your if statement becomes

If Me.NULLSUM = 0 And _
(Me.Status = 3 _
Or Me.Status = 7 _
Or Me.Status = 12 _
Or Me.Status = 22 _
Or Me.Status = 23) Then
 
T

tina

well, if you want to change *any* status to "Completed" when NULLSUM = 0,
then why bother to enumerate all the other statuses in the code? try

If Me!NULLSUM = 0 And _
Not (Me!Status = "Completed") Then
Msgbox "Change the status to completed."
End If

or, if you're always going to tell the user to change the status to
completed, why not just do it programmatically, as

Private Sub Form_AfterUpdate()

If Me!NULLSUM = 0 And _
Not (Me!Status = "Completed") Then
Me!Status = "Completed"
End If

End Sub

run the above code in the *subform's* AfterUpdate event.

hth
 
S

Sunflower

well, if you want to change *any* status to "Completed" when NULLSUM = 0,
then why bother to enumerate all the other statuses in the code? try

    If Me!NULLSUM = 0 And _
        Not (Me!Status = "Completed") Then
            Msgbox "Change the status to completed."
    End If

or, if you're always going to tell the user to change the status to
completed, why not just do it programmatically, as

Private Sub Form_AfterUpdate()

    If Me!NULLSUM = 0 And _
        Not (Me!Status = "Completed") Then
            Me!Status = "Completed"
    End If

End Sub

run the above code in the *subform's* AfterUpdate event.

hth

















- Show quoted text -

Sorry it took so long to respond...

I definitely like the idea of programmatically/automatically changing
the status to "Completed" when the value of NULLSUM =0

I placed your code:
--------------------------------------------------------------
Private Sub Form_AfterUpdate()
If Me!NULLSUM = 0 And _
Not (Me!Status = "Completed") Then
Me!Status = "Completed"
End If
End Sub
-------------------------------------------------------------

in the subform (subfrmLABORDETAIL1) AfterUpdate event.


However...
I get a Run-time error '2465":
cant find the field 'NULLSUM' referred to in your expression

Not sure where to go from here
 

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