Using Not Like In A Procedure

A

Arturo

I am using the following code to block entries that contain the letters “PXâ€.

Private Sub Destination_AfterUpdate()
If Destination Like "*PX*" Then
MsgBox "This is a Pyxis location." & Chr(10) & Chr(10) & _
"Please use the appropriate Pyxis input form for this
transaction." & Chr(10) & Chr(10) & _
"Thank you.", vbOKOnly, "INVALID ENTRY"
Destination.SetFocus
Destination = ""
End If
End Sub

Now, I would like to do just the opposite, i.e.,block orders that do not
have the PX letters. I tried to add "Not" in front of "Like" and it didn't
work. (If Destination Not Like "*PX*" Then)

What do I use to identify entries that do not have the letters “PX†in them?

Thank you.
 
S

Stefan Hoffmann

hi Arturo,
Now, I would like to do just the opposite, i.e.,block orders that do not
have the PX letters. I tried to add "Not" in front of "Like" and it didn't
work. (If Destination Not Like "*PX*" Then)
Simply change order:

If Not Destination Like "*PX*" Then ..


mfG
--> stefan <--
 
A

Andrew Tapp

Almost there, you should use;
If NOT Destination Like "*PX*" Then

Hope this helps.
 

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