I wrote a script and trying to get it to work. My Pass Through Query SQL is as follows:
SELECT UNO_Incidents.AssignedToGroup, UNO_Incidents.IncidentID, UNO_Incidents.Category, UNO_Incidents.SymptomDeviceAlias, UNO_Incidents.Priority, UNO_Incidents.Status, UNO_Incidents.Type, UNO_Incidents.Region, UNO_Incidents.AssetType, UNO_Incidents."Sym-Type", UNO_Incidents.SubmitterGroup, UNO_Incidents.Description, UNO_Incidents.CreatedBy, UNO_Incidents.AssignedToFullName, UNO_Incidents.DateCreated, UNO_Incidents."Restoral-Date/Time", UNO_Incidents."Occurrence-Date", UNO_Incidents.ResolutionCategory, UNO_Incidents.ResolutionSubCategory, UNO_Incidents.ResolutionSpecifics, UNO_Incidents.Impact, UNO_Incidents.Node, UNO_Incidents.ModifiedTime
FROM UNO_Incidents UNO_Incidents
WHERE (UNO_Incidents.AssignedToGroup='CORP - Huawei Tier II') AND (UNO_Incidents.DateCreated>={ts '2011-01-01 00:00:00'})
ORDER BY UNO_Incidents.DateCreated DESC
My VBA script
Private Sub Generate_Huawei_Tier_II_Report_Click()
On Error GoTo Err_Generate_Huawei_Tier_II_Report_Click
Dim stDocName As String
stDocName = " Huawei Tier II Report"
Dim stWhere As String
Dim strQueryName As String
strQueryName = "qryHuaweiTierII Query"
If Not IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] <= " & SQLDate(Me.txtEnding)
ElseIf IsDate(Me.txtBeginning) And Not IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] >= " & SQLDate(Me.txtBeginning)
ElseIf IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] Between #" & Me.txtBeginning & "# And #" & Me.txtEnding & "#"
End If
'MsgBox stWhere
Debug.Print "Beginning: " & Me.txtBeginning & "Ending: " & Me.txtEnding & " StWhere: " & stWhere
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
Exit_Generate_Huawei_Tier_II_Report_Click:
Exit Sub
Err_Generate_Huawei_Tier_II_Report_Click:
MsgBox Err.Description
End Sub
The error message I got was Compile error Sub or Function not defined
Help please?
SELECT UNO_Incidents.AssignedToGroup, UNO_Incidents.IncidentID, UNO_Incidents.Category, UNO_Incidents.SymptomDeviceAlias, UNO_Incidents.Priority, UNO_Incidents.Status, UNO_Incidents.Type, UNO_Incidents.Region, UNO_Incidents.AssetType, UNO_Incidents."Sym-Type", UNO_Incidents.SubmitterGroup, UNO_Incidents.Description, UNO_Incidents.CreatedBy, UNO_Incidents.AssignedToFullName, UNO_Incidents.DateCreated, UNO_Incidents."Restoral-Date/Time", UNO_Incidents."Occurrence-Date", UNO_Incidents.ResolutionCategory, UNO_Incidents.ResolutionSubCategory, UNO_Incidents.ResolutionSpecifics, UNO_Incidents.Impact, UNO_Incidents.Node, UNO_Incidents.ModifiedTime
FROM UNO_Incidents UNO_Incidents
WHERE (UNO_Incidents.AssignedToGroup='CORP - Huawei Tier II') AND (UNO_Incidents.DateCreated>={ts '2011-01-01 00:00:00'})
ORDER BY UNO_Incidents.DateCreated DESC
My VBA script
Private Sub Generate_Huawei_Tier_II_Report_Click()
On Error GoTo Err_Generate_Huawei_Tier_II_Report_Click
Dim stDocName As String
stDocName = " Huawei Tier II Report"
Dim stWhere As String
Dim strQueryName As String
strQueryName = "qryHuaweiTierII Query"
If Not IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] <= " & SQLDate(Me.txtEnding)
ElseIf IsDate(Me.txtBeginning) And Not IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] >= " & SQLDate(Me.txtBeginning)
ElseIf IsDate(Me.txtBeginning) And IsDate(Me.txtEnding) Then
stWhere = "[DateCreated] Between #" & Me.txtBeginning & "# And #" & Me.txtEnding & "#"
End If
'MsgBox stWhere
Debug.Print "Beginning: " & Me.txtBeginning & "Ending: " & Me.txtEnding & " StWhere: " & stWhere
DoCmd.OpenReport stDocName, acViewPreview, , stWhere
Exit_Generate_Huawei_Tier_II_Report_Click:
Exit Sub
Err_Generate_Huawei_Tier_II_Report_Click:
MsgBox Err.Description
End Sub
The error message I got was Compile error Sub or Function not defined
Help please?