Wrapping IF Statement (1 Viewer)

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
I have search the site, but obvious I didn't put in the right information.

This is a simple question. I have the following code:

Code:
If (Me.CatCode = "Claim already paid/MBR rates no further entitlements/Duplicate Claim.") Or (Me.CatCode = "Same city no entitlements / no per diem authorized in orders.") Then

I need to know how to wrap or continue the statement to the next line after the "Or".

Is this it:

Code:
If (Me.CatCode = "Claim already paid/MBR rates no further entitlements/Duplicate Claim.") Or _
(Me.CatCode = "Same city no entitlements / no per diem authorized in orders.") Then

Or is there an & or something?
 

dapfeifer

Bringing Maverick Mojo
Local time
Today, 02:24
Joined
Jun 17, 2008
Messages
68
Yes, you are missing the & before your _. Try


Code:
If (Me.CatCode = "Claim already paid/MBR rates no further entitlements/Duplicate Claim.") Or & _
(Me.CatCode = "Same city no entitlements / no per diem authorized in orders.") Then

This should work.
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
dapfeifer - Doesn't work. Now it throws and error in the compiler. is there "" somewhere in there or no. when it is just "_" compiler allows and eveything turns blue like it should.
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
Yes, you are missing the & before your _. Try
No....

Sorry & is only for continueing text strings.

his original code:


Code:
If (Me.CatCode = "Claim already paid/MBR rates no further entitlements/Duplicate Claim.") Or  _
   (Me.CatCode = "Same city no entitlements / no per diem authorized in orders.") Then

Tho that is some CatCode :(
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
namliam - so my code is correct?

What is wrong with the Catcode????? just curious what your thought was?
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
namliam - so my code is correct?

What is wrong with the Catcode????? just curious what your thought was?

Yes your code was correct IMHO.

For a "code" it is awfully long...
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
I know, Still working on the DB. In the beginning I knew nothing about how to create a DB, normalization, naming conventions and VBA. So there is a lot of work left to get everything as it should be.

I know that catcode should be and actuall code 1A or something that is associated with the actual text of the code, Just haven't gotten that far yet.

Thanks for pointing it though, Critism is always welcome Or any books to help me along in my quest for knowledge.
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
You seem to be on the "right path to redemption" ;)

Just stay away from the dark side ;)
 

fredalina

Registered User.
Local time
Today, 02:24
Joined
Jan 23, 2007
Messages
163
You could create variables for the two CatCode strings (which should be eligible for wrapping if still too wide) and use the variables in the If statement.
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
Fredalina - Thank you for the suggections. I have done that in the past, don't know why I didn't think of it this time...

You mean like this:
Code:
Dim t As String
Dim s As String

t = "Claim already paid/MBR rates no further entitlements/Duplicate Claim"
s = "Same city no entitlements / no per diem authorized in orders."


If ((Me.CatCode = "t") Or (Me.CatCode = "s"))
 

fredalina

Registered User.
Local time
Today, 02:24
Joined
Jan 23, 2007
Messages
163
Yay! My first successful response. Now maybe i won't feel like such a vampire, sucking the answers out of the rest of you.

i don't think you will need to put the variable name in "" if you put the string in quotes above. You should be able to do the first 4 lines as written but have the last line be:

If((Me.CatCode = t) Or (Me.CatCode = s)) Then...
 
Last edited:

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
Fredalina - Thank you for the suggections. I have done that in the past, don't know why I didn't think of it this time...
Sorry to stomp on Fredalina's parade but NOOOOOOOOOOOOOOOOOO! :eek:

This is the dark side!

If you do anything, please make the code a code like 1A like you suggested!

Also the If would be
If Me.CatCode = t Or Me.CatCode = s then

Also the statement you had was perfect
If me...... or _
me ..... then

Why change it? Maybe other than this:
If me...... _
or me ..... then
 

fredalina

Registered User.
Local time
Today, 02:24
Joined
Jan 23, 2007
Messages
163
Ah, well, i suppose vampires do come from the dark side. Watch for my fangs.
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
Ah, well, i suppose vampires do come from the dark side. Watch for my fangs.

No problem Fredalina, just keep reading and keep helping.

You will get better and better over time and will eventually start helping people instead of just leeching.
Also leeching here on the forum, you never know how your asking questions/leeching has allready helped other who searched and found your question and addapted it to solve their own issues.

I had someone respond a couple of months ago to a thread/question/problem I had some 4 years ago ! :eek: I was quite surprised to find all he said was " Thanks your problem solved mine" :)
These actuall responses are rare indeed, but you never know how many people actually read your stuff and find it usefull (atleast to some extend)

:cool:

So keep helping and leeching!
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
namliam - That was probably me responding on old post. I use the information from a lot of old post and reply saying thank you, when it worked for me as well.

Another question on If Statements.

Is this code correct for say all fields must be true or meet the requirements:

Code:
If (Not (IsNull(Me.CatCode)) And (Me.OrderType = "PRC") And (Me.ClaimType = "F")) Then

Basically saying Me.CatCode has something in it, and OrderType = PRC and ClaimType =F

Do I have the enough "(" or can I get rid of the one before "NOT" and the one at the end and get thesame results.
 

namliam

The Mailman - AWF VIP
Local time
Today, 09:24
Joined
Aug 11, 2003
Messages
11,695
you have enough AND can -if you like- get ride of most ()

If Not IsNull(Me.CatCode) And Me.OrderType = "PRC" And Me.ClaimType = "F" Then

() are only needed when you are working with AND and OR mixed in.... that goes broke if you dont bracket it... All ANDs ... or all ORs no need to use brackets.
 

Bigmo2u

Registered User.
Local time
Today, 02:24
Joined
Nov 29, 2005
Messages
200
namliam - Thank you so much for your help today. I have learned more from you today than I have from all the books I have read.
 

Users who are viewing this thread

Top Bottom