I am attempting to write an SQL statement in VBA that contains multiple "WHERE" conditions. Specifically, I want to filter where the "Assigned Reviewer" column is equal to a textbox in another form, and the value in the "AssociateReviewConversion" column is 2. When I run this code, it correctly applies the filter to "Assigned Reviewer" but does not apply the filter to the "AssociateReviewConverstion" column.
Code:
Dim strSource As String
strSource = "SELECT ID, Received, Event, [PRRB Case Number], [Red Flag], [Assigned Reviewer], AssociateReviewComplete, IntakeComplete, AssociateReviewConversion " & _
"FROM AssociateWindowQ " & _
"Where [Assigned Reviewer] Like '*" & Forms!Login!FirstName & "*' " _
& "And AssociateReviewConversion = 2"
Me.AssociateWindow.RowSource = strSource
Interestingly, when I modify the statement to only apply the filter to the "AssociateReviewConversion" field, it works correctly (see below).
Code:
Dim strSource As String
If [Forms]![Associate Review]![Complete] = -1 Then
strSource = "SELECT ID, Received, Event, [PRRB Case Number], [Red Flag], [Assigned Reviewer], AssociateReviewComplete, IntakeComplete, AssociateReviewConversion " & _
"FROM AssociateWindowQ " & _
"Where AssociateReviewConversion = 2"
Me.AssociateWindow.RowSource = strSource
Else
I just can't get the code to apply both criteria at the same time. Can someone tell me what I'm missing here?