1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| Function TBQS_ACTIVITE_ARS_V7()
Const TABLE_RESULTAT = "TB_ACTIVITE"
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Dim MonRs As ADODB.Recordset
Dim oField As ADODB.Field
Dim out_rst As Recordset
Dim Début As Date
Dim Fin As Date
'Initialisations
Début = Format(CDate("1/" & Format(DateAdd("m", -1, Date), "mm/yyyy")), "yyyy\-mm\-dd 00:00:00")
'Fin = Format(DateAdd("d", -1, CDate("1/" & Format(Date, "mm/yyyy"))), "yyyy\-mm\-dd 00:00:00")
Fin = Format(DateSerial(Year(Date), Month(Date), 1) - 1, "yyyy\-mm\-dd 00:00:00")Set out_rst = CurrentDb.OpenRecordset(TABLE_RESULTAT)
Set cn = New ADODB.Connection
cn.ConnectionString = Connexion_ARS_V7
cn.Open
Set cmd = New ADODB.Command
SQL = "SELECT Submit_Date, Product_Categorization_Tier_1, Product_Categorization_Tier_2, Product_Categorization_Tier_3, Incident_Number, Status, Assigned_Group, Assignee, Description, Contact_Company, Organization, Department, Submitter, Last_Name, Connexion, Direct_Contact_Last_Name, Priority, NbreAppels, Last_Resolved_Date, GCE_Environnement, GCE_Instance_de_production, Detailed_Decription, Last__Assigned_Date, " _
& "TicketType, Resolution, Resolution_Method, Last_Modified_Date, Owner_Support_Organization, Owner_Group " _
& "FROM HPD_Help_Desk " _
& "WHERE TicketType = 'Incident' " _
& "and Owner_Support_Organization = 'STAU' " _
& "and Product_Categorization_Tier_1 like 'Technique-%' " _
& "and Submit_Date >= {ts'" & Début & "'} " _
& "and Submit_Date <= {ts'" & Fin & "'} " _
& "ORDER BY Submit_Date"
' & "Status<>'Resolved' and Status <> 'Closed' "
Debug.Print SQL
With cmd
.ActiveConnection = cn
.CommandText = SQL
Set MonRs = cmd.Execute
End With
MonRs.Close
Set MonRs = Nothing
Set MonRs = New ADODB.Recordset
MonRs.Open cmd, , adOpenKeyset, adLockOptimistic, adCmdText
MonRs.MoveFirst
SQL = "DELETE * FROM " & TABLE_RESULTAT
CurrentDb.Execute SQL
Do While Not MonRs.EOF
out_rst.AddNew
For Each oField In MonRs.Fields
out_rst.Fields(oField.Name).Value = oField.Value
Next oField
out_rst.Update
MonRs.MoveNext
Loop
Set cn = Nothing
Set cmd = Nothing
Set out_rst = Nothing
Set MonRs = Nothing
End Function |
Partager