Trying to write vba to say if this field = this and this other field does not equal this then..

Here is what I'm trying to make work;

If [jmMtlSeq] = "9999" And [jmCommentText] is not like "OV*" Then
    tbxSupp = "Text"
    Else
...

Let me know if you need more information..

LVL 2
Jarred MeyerProduction ManagerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jarred MeyerProduction ManagerAuthor Commented:
P.S. this should be in just Access and probably VBA, Not SQL Query Syntax..
0
gman84Commented:
If (jmMtlSeq = "9999") AND Instr(jmCommentText,"OV") <> 1 Then
    tbxSupp = "Text"
Else
    ......
End If

Open in new window

0
Jarred MeyerProduction ManagerAuthor Commented:
That seems to have done the trick, although I'm getting #Error as my result when "Pending" is supposed to display.. Can you look at the complete code below and see if you can figure out what is wrong with the section I have where it should be returning "Pending"?

Thanks for the help!

Private Function txtPackSlip()

If ([jmMtlSeq] = "9999") And InStr([jmCommentText], "OV") <> 1 Then
    txtPackSlip = "S.C.O.C."
   
    Else

        If tbxSupp = "WAITING ON PO" Then
            txtPackSlip = "WAITING"
           
            Else
               
                If Not IsNull([jmCommentText]) Then
                txtPackSlip = [rdPackSlip]
               
                Else
                txtPackSlip = "Pending"

               
                End If
               
        End If
End If
   
   
End Function
0
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Rey Obrero (Capricorn1)Commented:


If [jmMtlSeq] = "9999" And NOT [jmCommentText] like "OV*" Then
    tbxSupp = "Text"
    Else
0
Jarred MeyerProduction ManagerAuthor Commented:
Capricorn.. That works as well..  Either of those methods work:)

Any thoughts on why my Pending part of this formula is returning #Error?
0
gman84Commented:
I think it's your use of IsNull()
This may work better
If [jmCommentText] <> vbNullString Then

Open in new window

0
Jarred MeyerProduction ManagerAuthor Commented:
That's still giving me #Error
0
Rey Obrero (Capricorn1)Commented:
try
Private Function txtPackSlip()

If ([jmMtlSeq] = "9999") And NOT [jmCommentText] like "OV*" Then
    txtPackSlip = "S.C.O.C."
   
    ElseIf tbxSupp = "WAITING ON PO" Then

        
       txtPackSlip = "WAITING"
           
    ElseIf  [jmCommentText] & "" <>"" Then
               
                
       txtPackSlip = [rdPackSlip]
               
    Else
      txtPackSlip = "Pending"
 
End If
   
   
End Function

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.