jeran042
Registered User.
- Local time
- Today, 10:17
- Joined
- Jun 26, 2017
- Messages
- 127
I can use someone's keen eye to help me troubleshoot my WHERE clause.
Here is what I have for code:
The Debug.Print sWhere returns:
The form opens, and the [COST_CENTER] criteria filters correctly, but the WHERE clause is not filtering the [CATEGORY]. I'm positive it has to do with the quotation marks.
Can someone please help me figure out where I am going wrong?
Much appreciated,
Here is what I have for code:
Code:
Private Sub txtSubscriptions_Click()
Dim sWhere As String
Dim sDepartment As String
sDepartment = DLookup("DEPARTMENT", "qryDepartment", "COST_CENTER= " & [txtCost_PROGRAM])
sWhere = "[COST_CENTER] = " & Me.txtCost_FRAT_MIS & " Or " _
& "[COST_CENTER] = " & Me.txtCost_CERE & " Or " _
& "[COST_CENTER] = " & Me.txtCost_SUPPORT & " Or " _
& "[COST_CENTER] = " & Me.txtCost_HISPANIC & " Or " _
& "[COST_CENTER] = " & Me.txtCost_MKTING & " Or " _
& "[COST_CENTER] = " & Me.txtCost_PROGRAM & " Or [COST_CENTER] = " & Me.txtCost_ONLINE & " And [CATEGORY] = " & "'" & "SUBSCRIPTIONS" & "'"
Debug.Print sWhere
If txtSubscriptions.value <> 0 Then
DoCmd.OpenForm "frm: Ledger Detail", acViewNormal, , sWhere, , acDialog
Else
MsgBox sDepartment & " has no records for: " & vbNewLine & _
"SUBSCRIPTIONS", vbInformation, "NO RECORDS"
End If
End Sub
The Debug.Print sWhere returns:
Code:
[COST_CENTER] = 1900 Or [COST_CENTER] = 1909 Or [COST_CENTER] = 1908 Or [COST_CENTER] = 1905 Or [COST_CENTER] = 1907 Or [COST_CENTER] = 1906 Or [COST_CENTER] = 1903 And [CATEGORY] = 'SUBSCRIPTIONS'
The form opens, and the [COST_CENTER] criteria filters correctly, but the WHERE clause is not filtering the [CATEGORY]. I'm positive it has to do with the quotation marks.
Can someone please help me figure out where I am going wrong?
Much appreciated,