donnie91910
asked on
VBA "or" Statement, parentheses in correct place.
VBA "or" Statement, parentheses in correct place. I am using paranthesis in my "or" statement.
I just wanted to check and make sure that they are in the right place. Mostly i am concerned with the beginning and ending parentheses in my statement.
Here is the code:
ElseIF (rstMasterView("TREE_SPECI ES_CD") = 4010 Or rstMasterView("TREE_SPECIE S_CD") = 4011 Or rstMasterView("TREE_SPECIE S_CD") = 4012 Or rstMasterView("TREE_SPECIE S_CD") = 4014 Or rstMasterView("TREE_SPECIE S_CD") = 4015 Or rstMasterView("TREE_SPECIE S_CD") = 4018) then
Thanks.
I just wanted to check and make sure that they are in the right place. Mostly i am concerned with the beginning and ending parentheses in my statement.
Here is the code:
ElseIF (rstMasterView("TREE_SPECI
Thanks.
It seems to be okay but I don't believe you need the beginning and ending parentheses.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, first line s/b
Select Case rstMasterView("TREE_SPECIE S_CD")
Select Case rstMasterView("TREE_SPECIE
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yes, VBA has Select Case, and I would use it in this case. Here is some typical Select Case code:
Select Case intChoice
Case 0
GoTo ErrorHandlerExit
Case 1
Call SendAcknowledgement(Me, lngID, strUserAID)
Case 2
Call CreateFirstReport(Me, lngID, strUserAID)
Case 3
Call CreateStatusReport(Me, lngID, strUserAID)
Case 4
strTemplate = "Dunn 1.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Envelope")
Case 5
strTemplate = "Dunn 1.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Attachment")
Case 6
strTemplate = "Dunn 2.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Envelope")
Case 7
strTemplate = "Dunn 2.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Attachment")
Case 8
strTemplate = "Dunn 3.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Envelope")
Case 9
strTemplate = "Dunn 3.dotx"
Call PrintLetter(lngID:=lngID, _
strUserAID:=strUserAID, _
strWordTemplate:=strTemplate, _
strInsured:=strInsured, _
strClaimant:=strClaimant, _
frm:=Me, _
strAppraiser:=strAppraiser, _
strEmailType:="Attachment")
End Select
This is Access VBA, but Select Case works in Excel VBA too.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Select case would indeed be a neater way of doing this
ASKER
thank you.