lostwithaccess
Registered User.
- Local time
- Today, 20:36
- Joined
- Apr 12, 2011
- Messages
- 69
Below is what I tried, but it seems to part run then gives the error "Syntax error in string in query question '((((qryPriorityPartnerships.txtInstitutionName)..............'
I have tried a couple of basic variations (at a guess..) but no joy. Not that I know what most of the other lines mean, but out of interest could you tell me what the line "strSQL = Left(strSQL, (Len(strSQL) - 5))" means?
Private Sub cmdDeptFilter_Click()
On Error GoTo Err_cmdDeptFilter_Click
Dim strSQL As String
Dim stDocName As String
stDocName = "View Priority Partnerships"
Dim strWHERE As String
strSQL = "(((qryPriorityPartnerships.txtInstitutionName)='A' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='B' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='C' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='D' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='E' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='F' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='G' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='H' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='I' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='J' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='K' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='L' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='M' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='N' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='O')) AND "
If Nz(Me.cboDept, "") <> "" Then
strSQL = strSQL & "Discipline='" & Me.cboDept & "' AND "
End If
strSQL = Left(strSQL, (Len(strSQL) - 5))
'Strip Last " And "
If strSQL <> "" Then
strSQL = Left(strSQL, (Len(strSQL) - 5))
Debug.Print strSQL
'Set the Filter property
DoCmd.OpenReport stDocName, acPreview
Reports![View Priority Partnerships].Filter = strSQL
Reports![View Priority Partnerships].FilterOn = True
RunCommand acCmdZoom75
blnNotOpenMenu = True
Else
MsgBox "No criteria specified, opening the report unfiltered"
DoCmd.OpenReport stDocName, acPreview
RunCommand acCmdZoom75
End If
Exit_cmdDeptFilter_Click:
Exit Sub
Err_cmdDeptFilter_Click:
MsgBox Err.Description
Resume Exit_cmdDeptFilter_Click
End Sub
I have tried a couple of basic variations (at a guess..) but no joy. Not that I know what most of the other lines mean, but out of interest could you tell me what the line "strSQL = Left(strSQL, (Len(strSQL) - 5))" means?
Private Sub cmdDeptFilter_Click()
On Error GoTo Err_cmdDeptFilter_Click
Dim strSQL As String
Dim stDocName As String
stDocName = "View Priority Partnerships"
Dim strWHERE As String
strSQL = "(((qryPriorityPartnerships.txtInstitutionName)='A' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='B' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='C' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='D' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='E' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='F' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='G' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='H' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='I' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='J' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='K' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='L' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='M' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='N' Or"
strSQL = strSQL & " (qryPriorityPartnerships.txtInstitutionName)='O')) AND "
If Nz(Me.cboDept, "") <> "" Then
strSQL = strSQL & "Discipline='" & Me.cboDept & "' AND "
End If
strSQL = Left(strSQL, (Len(strSQL) - 5))
'Strip Last " And "
If strSQL <> "" Then
strSQL = Left(strSQL, (Len(strSQL) - 5))
Debug.Print strSQL
'Set the Filter property
DoCmd.OpenReport stDocName, acPreview
Reports![View Priority Partnerships].Filter = strSQL
Reports![View Priority Partnerships].FilterOn = True
RunCommand acCmdZoom75
blnNotOpenMenu = True
Else
MsgBox "No criteria specified, opening the report unfiltered"
DoCmd.OpenReport stDocName, acPreview
RunCommand acCmdZoom75
End If
Exit_cmdDeptFilter_Click:
Exit Sub
Err_cmdDeptFilter_Click:
MsgBox Err.Description
Resume Exit_cmdDeptFilter_Click
End Sub