L
LeftyLeo via AccessMonster.com
I am having trouble with the following code, it gives me a missing operator
error on the first line can anyone help me figure it out.
Private Sub cmdFocusArea_Click()
Dim strSql As String
Dim qdf As QueryDef
Dim blWhere As Boolean
'Create query definitions for qryReports recordsource of rptStoreBudget
DoCmd.Hourglass True
DoCmd.SetWarnings False
If Not IsNull(Me.cboQtr.Value) Then
strQtrFilter = PeriodsPerQtr(Me.cboQtr.Value)
End If
Errors here I am suspecting the Is Not Null line
'Write begining of SQL statement
strSql = "SELECT tblMasterTable.fldDate, tblMasterTable.fldLocation,
tblMasterTable.fldZone, tblQuarters.fldQuarter, tblMasterTable.fldPeriod,
tblMasterTable.fldYear, tblMasterTable.fldOrganization, tblMasterTable.[Focus
Area], tblMasterTable.fldAmount FROM tblMasterTable INNER JOIN tblQuarters ON
tblMasterTable.fldPeriod=tblQuarters.fldPeriod WHERE (tblMasterTable.[Focus
Area]) Is Not Null "
'Set Where Clause variable to False to initialize
blWhere = False
'User has entered criteria for the Year
If Not Me.cboYear.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & "(tblMasterTable.fldYear)=[forms]![frmAdminReport]!
[cboYear]"
End If
'User has entered criteria for the Quarter, add to Where clause
If Not Me.cboQtr.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblQuarters.fldQuarter)=[forms]![frmAdminReport]!
[cboQtr]"
' strSql = strSql & "(tblMasterTable.fldPeriod) =" & strQtrFilter
End If
'User has entered criteria for the Period
If Not Me.cboPeriod.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldPeriod)=[forms]![frmAdminReport]!
[cboPeriod]"
End If
'User has entered criteria for the Zone
If Not Me.cboZone.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldZone)=[forms]![frmAdminReport]!
[cboZone]"
End If
'User has entered criteria for the Location
If Not Me.cboLocation.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldLocation)=[forms]![frmAdminReport]
![cboLocation]"
End If
strSql = strSql & ";"
Set qdf = CurrentDb.QueryDefs("qryFocusAreas")
qdf.SQL = strSql
qdf.Close
If DCount("*", "qryFocusAreas") > 0 Then
DoCmd.OpenReport "rptFocusAreas", acViewPreview
Else
MsgBox "There is no data available for criteria selected. Revise and
try again. Thank-you!", vbExclamation, "No Data"
End If
DoCmd.Hourglass False
DoCmd.SetWarnings True
End Sub
error on the first line can anyone help me figure it out.
Private Sub cmdFocusArea_Click()
Dim strSql As String
Dim qdf As QueryDef
Dim blWhere As Boolean
'Create query definitions for qryReports recordsource of rptStoreBudget
DoCmd.Hourglass True
DoCmd.SetWarnings False
If Not IsNull(Me.cboQtr.Value) Then
strQtrFilter = PeriodsPerQtr(Me.cboQtr.Value)
End If
Errors here I am suspecting the Is Not Null line
'Write begining of SQL statement
strSql = "SELECT tblMasterTable.fldDate, tblMasterTable.fldLocation,
tblMasterTable.fldZone, tblQuarters.fldQuarter, tblMasterTable.fldPeriod,
tblMasterTable.fldYear, tblMasterTable.fldOrganization, tblMasterTable.[Focus
Area], tblMasterTable.fldAmount FROM tblMasterTable INNER JOIN tblQuarters ON
tblMasterTable.fldPeriod=tblQuarters.fldPeriod WHERE (tblMasterTable.[Focus
Area]) Is Not Null "
'Set Where Clause variable to False to initialize
blWhere = False
'User has entered criteria for the Year
If Not Me.cboYear.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & "(tblMasterTable.fldYear)=[forms]![frmAdminReport]!
[cboYear]"
End If
'User has entered criteria for the Quarter, add to Where clause
If Not Me.cboQtr.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblQuarters.fldQuarter)=[forms]![frmAdminReport]!
[cboQtr]"
' strSql = strSql & "(tblMasterTable.fldPeriod) =" & strQtrFilter
End If
'User has entered criteria for the Period
If Not Me.cboPeriod.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldPeriod)=[forms]![frmAdminReport]!
[cboPeriod]"
End If
'User has entered criteria for the Zone
If Not Me.cboZone.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldZone)=[forms]![frmAdminReport]!
[cboZone]"
End If
'User has entered criteria for the Location
If Not Me.cboLocation.Value = "" Then
If blWhere = True Then
strSql = strSql & " AND "
Else
strSql = strSql & " WHERE "
blWhere = True
End If
strSql = strSql & " (tblMasterTable.fldLocation)=[forms]![frmAdminReport]
![cboLocation]"
End If
strSql = strSql & ";"
Set qdf = CurrentDb.QueryDefs("qryFocusAreas")
qdf.SQL = strSql
qdf.Close
If DCount("*", "qryFocusAreas") > 0 Then
DoCmd.OpenReport "rptFocusAreas", acViewPreview
Else
MsgBox "There is no data available for criteria selected. Revise and
try again. Thank-you!", vbExclamation, "No Data"
End If
DoCmd.Hourglass False
DoCmd.SetWarnings True
End Sub