I need some help with parenthesis. I am not sure how to use parenthesis when determining a string value. Everything I have tried doesn't seem to work. I want the results for when the cboCharacter.value is in either the [Imprint Character 1] field OR the [Imprint Character 2] field AND the cboScoring.Value is in the Scoring field.
Where should the parenthesis be placed in the code?
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT [Product Name], NDC, [Imprint Number 1], " & _
"[Imprint Character 1], [Imprint Number 2], [Imprint Character 2], [COLOR=1], [COLOR=2], Shape, Scoring, Coating FROM ProductDescriptionTable = '"
Private Const strSQL9 = "' WHERE Scoring = '"
Private Const strSQL20 = "' AND [Imprint Character 1] = '"
Private Const strSQL21 = "' OR [Imprint Character 2] = '"
Private intCtr As Integer
Private strSQL As String
Private Sub FillList()
If Me!cboProductName.Value = "(All)" And Me!cboColor.Value = "(All)" And &
Me!cboImprintNumber.Value = "(All)" And Me!cboShape.Value = "(All)"
Then strSQL = strSQL1 & strSQL9 & Me!cboScoring.Value & strSQL20 &
Me!cboCharacter.Value & strSQL21 Me!cboCharacter.Value
Else
strSQL = strSQL1 & Me!cboProductName.Value & strSQL2 & Me!cboShape.Value &
strSQL9 & Me!cboScoring.Value & strSQL19 & Me!cboColor.Value & strSQL20 &
Me!cboCharacter.Value & strSQL21 & Me!cboImprintNumber.Value
End If
Where should the parenthesis be placed in the code?
Option Compare Database
Option Explicit
Private Const strSQL1 = "SELECT [Product Name], NDC, [Imprint Number 1], " & _
"[Imprint Character 1], [Imprint Number 2], [Imprint Character 2], [COLOR=1], [COLOR=2], Shape, Scoring, Coating FROM ProductDescriptionTable = '"
Private Const strSQL9 = "' WHERE Scoring = '"
Private Const strSQL20 = "' AND [Imprint Character 1] = '"
Private Const strSQL21 = "' OR [Imprint Character 2] = '"
Private intCtr As Integer
Private strSQL As String
Private Sub FillList()
If Me!cboProductName.Value = "(All)" And Me!cboColor.Value = "(All)" And &
Me!cboImprintNumber.Value = "(All)" And Me!cboShape.Value = "(All)"
Then strSQL = strSQL1 & strSQL9 & Me!cboScoring.Value & strSQL20 &
Me!cboCharacter.Value & strSQL21 Me!cboCharacter.Value
Else
strSQL = strSQL1 & Me!cboProductName.Value & strSQL2 & Me!cboShape.Value &
strSQL9 & Me!cboScoring.Value & strSQL19 & Me!cboColor.Value & strSQL20 &
Me!cboCharacter.Value & strSQL21 & Me!cboImprintNumber.Value
End If