Version =20 VersionRequired =20 Begin Form DividingLines = NotDefault AllowAdditions = NotDefault FilterOn = NotDefault AllowDesignChanges = NotDefault PictureAlignment =2 DatasheetGridlinesBehavior =3 GridY =10 Width =12245 DatasheetFontHeight =11 ItemSuffix =15 Right =10395 Bottom =12345 DatasheetGridlinesColor =14806254 Filter ="[NomBareme]='Frais Kilométriques (11)' AND [PeriodeValidite]=1" RecSrcDt = Begin 0xf052af211737e440 End RecordSource ="SELECT tbl_baremes.NomBareme, tbl_baremes.PeriodeValidite, tbl_baremes.BorneInf," " tbl_baremes.BorneSup, tbl_baremes.UniteBornes, tbl_baremes.Valeur, tbl_baremes." "UniteValeur, tbl_baremes.Commentaire FROM tbl_baremes ORDER BY tbl_baremes.Borne" "Inf; " AfterUpdate ="[Event Procedure]" OnOpen ="[Event Procedure]" DatasheetFontName ="Calibri" FilterOnLoad =0 ShowPageMargins =0 DisplayOnSharePointSite =1 DatasheetAlternateBackColor =15921906 DatasheetGridlinesColor12 =0 FitToScreen =1 DatasheetBackThemeColorIndex =1 BorderThemeColorIndex =3 ThemeFontIndex =1 ForeThemeColorIndex =0 AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 Begin Begin Label BackStyle =0 FontSize =11 FontName ="Calibri" ThemeFontIndex =1 BackThemeColorIndex =1 BorderThemeColorIndex =0 BorderTint =50.0 ForeThemeColorIndex =0 ForeTint =50.0 GridlineThemeColorIndex =1 GridlineShade =65.0 End Begin CommandButton Width =1701 Height =283 FontSize =11 FontWeight =400 FontName ="Calibri" ForeThemeColorIndex =0 ForeTint =75.0 GridlineThemeColorIndex =1 GridlineShade =65.0 UseTheme =1 Shape =1 Gradient =12 BackThemeColorIndex =4 BackTint =60.0 BorderLineStyle =0 BorderColor =16777215 BorderThemeColorIndex =4 BorderTint =60.0 ThemeFontIndex =1 HoverThemeColorIndex =4 HoverTint =40.0 PressedThemeColorIndex =4 PressedShade =75.0 HoverForeThemeColorIndex =0 HoverForeTint =75.0 PressedForeThemeColorIndex =0 PressedForeTint =75.0 End Begin TextBox AddColon = NotDefault FELineBreak = NotDefault BorderLineStyle =0 Width =1701 LabelX =-1701 FontSize =11 FontName ="Calibri" AsianLineBreak =1 BackThemeColorIndex =1 BorderThemeColorIndex =1 BorderShade =65.0 ThemeFontIndex =1 ForeThemeColorIndex =0 ForeTint =75.0 GridlineThemeColorIndex =1 GridlineShade =65.0 End Begin ComboBox AddColon = NotDefault BorderLineStyle =0 Width =1701 LabelX =-1701 FontSize =11 FontName ="Calibri" AllowValueListEdits =1 InheritValueList =1 ThemeFontIndex =1 BackThemeColorIndex =1 BorderThemeColorIndex =1 BorderShade =65.0 ForeThemeColorIndex =2 ForeShade =50.0 GridlineThemeColorIndex =1 GridlineShade =65.0 End Begin FormHeader Height =2607 BackColor =10855845 Name ="EntêteFormulaire" AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 Begin Begin Label OverlapFlags =93 Left =624 Width =3986 Height =334 FontSize =13 BorderColor =8355711 Name ="Étiquette7" Caption ="Mise à jour du barème:" GridlineColor =10921638 LayoutCachedLeft =624 LayoutCachedWidth =4610 LayoutCachedHeight =334 ForeTint =100.0 End Begin CommandButton OverlapFlags =85 Width =576 Height =351 ForeColor =4210752 Name ="Commande16" Caption ="Commande16" ControlTipText ="Fermer formulaire" GridlineColor =10921638 OnClickEmMacro = Begin Version =196611 ColumnsShown =8 Begin Action ="Close" Argument ="-1" Argument ="" Argument ="0" End Begin Comment ="_AXL:\015\012" End Begin Comment ="_AXL:" End End ImageData = Begin 0x2800000010000000100000000100200000000000000000000000000000000000 , 0x0000000000000000000000000000000000000000000000000000000010081080 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x000000000000000000000000000000000000000040485020100810e0104050ff , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000000000000000000040404080405860ff106890ff2080a0f0 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000607070ff80a0b0ff4080a0ff20a0d0ff40a8e0ff2078a0ff , 0x101020ff101020ff000000000000000000000000000000000000000000000000 , 0x0000000000000000708890ffa0d8f0ff60d0ffff50c0f0ff30a8e0ff1080b0ff , 0xe0d8d0ff102020ff000000000000000000000000000000000000000000000000 , 0x0000000000000000708890ffb0e8f0ff80e0ffff60c8f0ff50b8f0ff1088c0ff , 0xf0d8d0ff202830ff000000000000000090482030904820ff0000000000000000 , 0x0000000000000000808890ffb0e8f0ff80e0ffff60d0ffff404050ff1090c0ff , 0xf0e0d0ff303840ff0000000090482030a05030ffa05020ff0000000000000000 , 0x00000000000000008090a0ffc0f0ffff90e0ffff70d8ffff60c8f0ff0090c0ff , 0xf0e0e0ff404050ff90482030a05030ffd07840ffb05830ffa05020ffa04820ff , 0x904820ff904820ff8090a0ffc0f0ffffa0e8ffff80d8ffff70d0f0ff40b0e0ff , 0xf0e8e0ff605050ffa05830ffe08860fff09060fff08850ffe07850ffd07040ff , 0xb06840ff904820ff8098a0ffc0f0ffffa0e8ffff90e8ffff80e0ffff80b8d0ff , 0xf0e8e0ffe09870ffffc0a0ffffb090ffffa070fff09060fff08850ffe07850ff , 0xd07040ffa05020ff8098a0ffc0f0ffffc0f8ffffa0e0f0ff90a8b0ffc0c8d0ff , 0xf0f0e0ff908080fff0a070ffffc0a0ffffb090ffffb090ffffa880fff0a080ff , 0xe09870ffb05030ff90a0a0ffe0f8ffffb0c8d0ff90a0b0fff0f0f0fffff8f0ff , 0xf0f0f0ff607080ffe0987050f0a070ffffc0a0ffd06830ffe09870ffe09060ff , 0xe08860ffe08050ff90a0b0ff90a8b0ffc0c8d0ffffffffffffffffffffffffff , 0xffffffff708890ff00000000e0987050e09870ffd07040ff0000000000000000 , 0x000000000000000090a0b0ff90a0b0ff90a0b0ff90a0b0ff90a0a0ff8098a0ff , 0x8098a0ff9098a0ff0000000000000000e0987050e09870ff0000000000000000 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000000000000000000000000000000000000000000000000000 , 0x0000000000000000 End LayoutCachedWidth =576 LayoutCachedHeight =351 Gradient =0 BackColor =14277081 BackThemeColorIndex =1 BackTint =100.0 BackShade =85.0 BorderColor =14136213 HoverColor =15060409 PressedColor =9592887 HoverForeColor =4210752 PressedForeColor =4210752 WebImagePaddingLeft =2 WebImagePaddingTop =2 WebImagePaddingRight =1 WebImagePaddingBottom =1 End Begin Label OverlapFlags =93 Left =965 Top =850 Width =4425 Height =345 BorderColor =8355711 Name ="txt_ancdate" Caption ="Les données ci dessous sont valables depuis le " GridlineColor =10921638 LayoutCachedLeft =965 LayoutCachedTop =850 LayoutCachedWidth =5390 LayoutCachedHeight =1195 ForeTint =100.0 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =8787 Top =853 Width =1476 Height =315 ColumnOrder =1 TabIndex =1 BorderColor =10921638 ForeColor =4210752 Name ="DateInf" GridlineColor =10921638 LayoutCachedLeft =8787 LayoutCachedTop =853 LayoutCachedWidth =10263 LayoutCachedHeight =1168 End Begin Label OverlapFlags =85 Left =965 Top =1255 Width =7710 Height =285 BorderColor =8355711 Name ="txt_nvdate" Caption ="Veuillez choisir la date à partir de laquelle les nouvelles données prendront e" "ffet:" GridlineColor =10921638 LayoutCachedLeft =965 LayoutCachedTop =1255 LayoutCachedWidth =8675 LayoutCachedHeight =1540 ForeTint =100.0 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =8787 Top =1250 Width =1474 Height =315 ColumnOrder =2 TabIndex =2 BorderColor =10921638 ForeColor =4210752 Name ="NvelleDate" Format ="Short Date" GridlineColor =10921638 LayoutCachedLeft =8787 LayoutCachedTop =1250 LayoutCachedWidth =10261 LayoutCachedHeight =1565 End Begin Label OverlapFlags =85 Left =963 Top =1647 Width =6480 Height =345 BorderColor =8355711 Name ="txt_copie" Caption ="Voulez vous utiliser les anciennes données comme point de départ?" GridlineColor =10921638 LayoutCachedLeft =963 LayoutCachedTop =1647 LayoutCachedWidth =7443 LayoutCachedHeight =1992 ForeTint =100.0 End Begin ComboBox LimitToList = NotDefault RowSourceTypeInt =1 OverlapFlags =85 IMESentenceMode =3 ColumnCount =2 ListWidth =1442 Left =8787 Top =1647 Width =1476 Height =315 ColumnOrder =3 TabIndex =3 BorderColor =10921638 ForeColor =4138256 Name ="CopieAnc" RowSourceType ="Value List" RowSource ="1;\"Oui\";0;\"Non\"" ColumnWidths ="0;1442" GridlineColor =10921638 LayoutCachedLeft =8787 LayoutCachedTop =1647 LayoutCachedWidth =10263 LayoutCachedHeight =1962 End Begin TextBox Locked = NotDefault FontItalic = NotDefault OldBorderStyle =0 OverlapFlags =93 BackStyle =0 IMESentenceMode =3 Left =11622 Top =56 Width =501 Height =315 ColumnOrder =4 FontSize =9 TabIndex =4 BorderColor =10921638 ForeColor =4210752 Name ="PeriodeValidite" ControlSource ="PeriodeValidite" StatusBarText ="cf. tbl_PeriodeAgent" GridlineColor =10921638 LayoutCachedLeft =11622 LayoutCachedTop =56 LayoutCachedWidth =12123 LayoutCachedHeight =371 End Begin CommandButton OverlapFlags =85 Left =10431 Top =1647 Width =1077 TabIndex =5 ForeColor =4210752 Name ="CmdOK" Caption ="OK" OnClick ="[Event Procedure]" GridlineColor =10921638 LayoutCachedLeft =10431 LayoutCachedTop =1647 LayoutCachedWidth =11508 LayoutCachedHeight =1930 Gradient =0 BackColor =15921906 BackThemeColorIndex =1 BackTint =100.0 BackShade =95.0 BorderColor =14136213 HoverColor =15060409 PressedColor =9592887 HoverForeColor =4210752 PressedForeColor =4210752 WebImagePaddingLeft =2 WebImagePaddingTop =2 WebImagePaddingRight =1 WebImagePaddingBottom =1 End Begin Label Visible = NotDefault OverlapFlags =215 Left =963 Top =567 Width =6855 Height =630 BorderColor =8355711 Name ="txt_edition" Caption ="Veuillez renseigner ci dessous les nouvelles informations de l'agent. Elles sero" "nt prises en compte à partir du:" GridlineColor =10921638 LayoutCachedLeft =963 LayoutCachedTop =567 LayoutCachedWidth =7818 LayoutCachedHeight =1197 ForeTint =100.0 End Begin Label FontItalic = NotDefault OverlapFlags =247 Left =9411 Top =56 Width =2385 Height =225 FontSize =9 BorderColor =8355711 ForeColor =8355711 Name ="Étiquette46" Caption ="Code de la période affichée:" GridlineColor =10921638 LayoutCachedLeft =9411 LayoutCachedTop =56 LayoutCachedWidth =11796 LayoutCachedHeight =281 End Begin TextBox OldBorderStyle =0 OverlapFlags =215 BackStyle =0 IMESentenceMode =3 Left =3174 Width =3696 Height =315 ColumnWidth =2790 ColumnOrder =0 FontSize =13 TabIndex =6 BorderColor =10921638 Name ="NomBareme" ControlSource ="NomBareme" GridlineColor =10921638 LayoutCachedLeft =3174 LayoutCachedWidth =6870 LayoutCachedHeight =315 ForeTint =100.0 End End End Begin Section Height =453 BackColor =14211288 Name ="Détail" AlternateBackColor =15921906 AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 Begin Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =1190 Top =56 Width =1086 Height =315 BorderColor =10921638 ForeColor =4210752 Name ="BorneInf" ControlSource ="BorneInf" GridlineColor =10921638 LayoutCachedLeft =1190 LayoutCachedTop =56 LayoutCachedWidth =2276 LayoutCachedHeight =371 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =2777 Top =56 Width =1026 Height =315 TabIndex =1 BorderColor =10921638 ForeColor =4210752 Name ="BorneSup" ControlSource ="BorneSup" GridlineColor =10921638 LayoutCachedLeft =2777 LayoutCachedTop =56 LayoutCachedWidth =3803 LayoutCachedHeight =371 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =3911 Top =56 Width =786 Height =315 TabIndex =2 BorderColor =10921638 ForeColor =4210752 Name ="UniteBornes" ControlSource ="UniteBornes" GridlineColor =10921638 LayoutCachedLeft =3911 LayoutCachedTop =56 LayoutCachedWidth =4697 LayoutCachedHeight =371 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =5612 Top =56 Height =315 TabIndex =3 BorderColor =10921638 ForeColor =4210752 Name ="Valeur" ControlSource ="Valeur" GridlineColor =10921638 LayoutCachedLeft =5612 LayoutCachedTop =56 LayoutCachedWidth =7313 LayoutCachedHeight =371 End Begin TextBox OverlapFlags =85 IMESentenceMode =3 Left =7426 Top =56 Width =636 Height =315 TabIndex =4 BorderColor =10921638 ForeColor =4210752 Name ="UniteValeur" ControlSource ="UniteValeur" GridlineColor =10921638 LayoutCachedLeft =7426 LayoutCachedTop =56 LayoutCachedWidth =8062 LayoutCachedHeight =371 End Begin Label OverlapFlags =85 Left =623 Top =56 Width =450 Height =315 BorderColor =8355711 Name ="Étiquette0" Caption ="De: " GridlineColor =10921638 LayoutCachedLeft =623 LayoutCachedTop =56 LayoutCachedWidth =1073 LayoutCachedHeight =371 ForeTint =100.0 End Begin Label OverlapFlags =85 Left =2324 Top =56 Width =390 Height =315 BorderColor =8355711 Name ="Étiquette1" Caption ="à:" GridlineColor =10921638 LayoutCachedLeft =2324 LayoutCachedTop =56 LayoutCachedWidth =2714 LayoutCachedHeight =371 ForeTint =100.0 End Begin Label OverlapFlags =85 Left =4818 Top =56 Width =690 Height =315 BorderColor =8355711 Name ="Étiquette3" Caption ="=>" GridlineColor =10921638 LayoutCachedLeft =4818 LayoutCachedTop =56 LayoutCachedWidth =5508 LayoutCachedHeight =371 ForeTint =100.0 End Begin CommandButton OverlapFlags =85 Left =8220 Top =56 Width =1922 TabIndex =5 ForeColor =4210752 Name ="InserLigne" Caption ="Insérer une ligne" OnClick ="[Event Procedure]" GridlineColor =10921638 LayoutCachedLeft =8220 LayoutCachedTop =56 LayoutCachedWidth =10142 LayoutCachedHeight =339 Gradient =0 BackColor =15921906 BackThemeColorIndex =1 BackTint =100.0 BackShade =95.0 BorderColor =14136213 HoverColor =15060409 PressedColor =9592887 HoverForeColor =4210752 PressedForeColor =4210752 WebImagePaddingLeft =2 WebImagePaddingTop =2 WebImagePaddingRight =1 WebImagePaddingBottom =1 End Begin CommandButton OverlapFlags =85 Left =10204 Top =56 Width =1922 TabIndex =6 ForeColor =4210752 Name ="SupprLigne" Caption ="Supprimer la ligne" OnClick ="[Event Procedure]" GridlineColor =10921638 LayoutCachedLeft =10204 LayoutCachedTop =56 LayoutCachedWidth =12126 LayoutCachedHeight =339 Gradient =0 BackColor =15921906 BackThemeColorIndex =1 BackTint =100.0 BackShade =95.0 BorderColor =14136213 HoverColor =15060409 PressedColor =9592887 HoverForeColor =4210752 PressedForeColor =4210752 WebImagePaddingLeft =2 WebImagePaddingTop =2 WebImagePaddingRight =1 WebImagePaddingBottom =1 End End End Begin FormFooter Height =0 BackColor =14211288 Name ="PiedFormulaire" AlternateBackThemeColorIndex =1 AlternateBackShade =95.0 End End End CodeBehindForm Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = True Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Compare Database Private Sub CmdOK_Click() Dim rs As DAO.Recordset Dim NvPeriode, copie, i, j, k As Integer Dim NvelleDate As Date Dim NomBareme As String Dim ACopier() As Variant NomBareme = Me.NomBareme If IsNull(Me.NvelleDate) Then MsgBox "Vous devez choisir une date de début pour la nouvelle période." Me.NvelleDate.BackColor = 33023 Exit Sub End If NvelleDate = CDate(Me.NvelleDate) copie = Nz(Me.CopieAnc.Column(0), 1) NvPeriode = NvellePeriode("tbl_PeriodeBareme", NomBareme, NvelleDate) If NvPeriode = 0 Then Exit Sub Call VerrouMAJbareme(0) Set rs = CurrentDb.OpenRecordset("SELECT * FROM tbl_baremes WHERE [NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & Me.PeriodeValidite & ";") If rs.RecordCount = 0 Then copie = 0 rs.MoveLast rs.MoveFirst ReDim ACopier(rs.Fields.Count - 1, rs.RecordCount) k = rs.RecordCount Do Until rs.EOF = True For i = 0 To rs.Fields.Count - 1 'on copie de toute façon le nom et le commentaire If rs.Fields(i).Name = "NomBareme" Or rs.Fields(i).Name = "Commentaire" Then ACopier(i, rs.AbsolutePosition) = rs.Fields(i) ElseIf rs.Fields(i).Name = "PeriodeValidite" Then ACopier(i, rs.AbsolutePosition) = NvPeriode Else If copie = 1 Then ACopier(i, rs.AbsolutePosition) = rs.Fields(i) Else ACopier(i, rs.AbsolutePosition) = Null End If End If Next i rs.MoveNext Loop Set rs = Nothing 'création d'une ou plusieurs nouvelle(s) ligne(s) dans la table tbl_baremes Set rs = CurrentDb.OpenRecordset("tbl_baremes") For j = 0 To k - 1 rs.AddNew For i = 0 To rs.Fields.Count - 1 rs.Fields(i) = ACopier(i, j) Next i rs.Update Next j 'on place l'enregistrement du formulaire sur ce nouvel enregistrement Me.FilterOn = False Me.Filter = "[NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & NvPeriode Me.FilterOn = True Call CreerMsg(11, , NomBareme, NvPeriode) Me.Refresh Call VerrouMAJbareme(2) End Sub Private Sub Form_AfterUpdate() Me.Requery Me.Refresh Me.DateInf = DLookup("[DateInf]", "[tbl_periodebareme]", "[NomBareme]='" & Me.NomBareme & "' AND [CodePeriode]=" & Me.PeriodeValidite) End Sub Private Sub Form_Open(Cancel As Integer) Me.NvelleDate = "01/" & Format(Month(Now()), "00") & "/" & Year(Now()) Me.CopieAnc = 1 Me.DateInf = DLookup("[DateInf]", "[tbl_periodebareme]", "[NomBareme]='" & Me.NomBareme & "' AND [CodePeriode]=" & Me.PeriodeValidite) Call VerrouMAJbareme(1) End Sub Private Sub InserLigne_Click() Dim NomBareme, UniteBornes, UniteValeur, commentaire As String Dim PeriodeValidite As Integer Dim BorneInf, Valeur As Double Dim rs As DAO.Recordset If IsNull(NomBareme) Or IsNull(PeriodeValidite) Or IsNull(Valeur) Then MsgBox "Erreur: certains paramètres sont manquants" Exit Sub End If NomBareme = Me.NomBareme PeriodeValidite = Me.PeriodeValidite UniteBornes = Nz(Me.UniteBornes, "") UniteValeur = Nz(Me.UniteValeur, "") BorneInf = Nz(Me.BorneInf, 0) Valeur = Nz(Me.Valeur, 0) commentaire = Nz(DLookup("Commentaire", "tbl_baremes", "[NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & PeriodeValidite), "") Set rs = CurrentDb.OpenRecordset("tbl_baremes") rs.AddNew rs![NomBareme] = NomBareme rs![PeriodeValidite] = PeriodeValidite rs![UniteBornes] = UniteBornes rs![UniteValeur] = UniteValeur rs![BorneInf] = BorneInf rs![BorneSup] = BorneInf rs![Valeur] = Valeur rs![commentaire] = commentaire rs.Update Me.Requery Me.Refresh End Sub Private Sub SupprLigne_Click() Dim NomBareme, sql As String Dim PeriodeValidite, compte, avertissement As Integer Dim BorneInf, Valeur As Double NomBareme = Me.NomBareme PeriodeValidite = Me.PeriodeValidite BorneInf = Nz(Me.BorneInf, -1) BorneSup = Nz(Me.BorneSup, -1) Valeur = Nz(Me.Valeur, 0) compte = Nz(DCount("NomBareme", "tbl_baremes", "[NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & PeriodeValidite), 0) Select Case compte Case 0 MsgBox "Erreur: aucune ligne trouvée" Exit Sub Case 1 MsgBox "Vous ne pouvez supprimer une ligne d'un barème que si celui-ci présente plusieurs lignes." Exit Sub Case Is > 1 avertissement = DLookup("[valeur]", "tbl_parametre", "[parametre]='avertSQL'") If avertissement = 0 Then DoCmd.SetWarnings False If BorneInf = -1 And BorneSup = -1 Then sql = "DELETE * FROM tbl_Baremes WHERE [NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & PeriodeValidite & " AND [Valeur] = " & Valeur & ";" ElseIf BorneInf >= 0 And BorneSup = -1 Then sql = "DELETE * FROM tbl_Baremes WHERE [NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & PeriodeValidite & " AND [Valeur] = " & Valeur & " AND [BorneInf]=" & BorneInf & ";" ElseIf BorneInf >= 0 And BorneSup >= 0 Then sql = "DELETE * FROM tbl_Baremes WHERE [NomBareme]='" & NomBareme & "' AND [PeriodeValidite]=" & PeriodeValidite & " AND [Valeur] = " & Valeur & " AND [BorneInf]=" & BorneInf & " AND [BorneSup]=" & BorneSup & ";" End If DoCmd.RunSQL sql DoCmd.SetWarnings True Me.Refresh End Select End Sub