Attribute VB_Name = "Functions" Option Compare Database Public Function KalDnyMth(ParObd As String) As Integer 'Funkce pro výpočet počtu kalendářních dnů v daném měsíci KalDnyMth = DateDiff("d", DateSerial(Left([ParObd], 4), Val(Right([ParObd], 2)), 1), DateSerial(Left([ParObd], 4), Val(Right([ParObd], 2)) + 1, 1)) End Function Public Function KalDnyYTM(ParObd1 As String) As Integer 'Funkce pro výpočet počtu kalendářních dnů od počátku roku do konce daného měsíce KalDnyYTM = DateDiff("d", DateSerial(Left([ParObd1], 4), 1, 1), DateSerial(Left([ParObd1], 4), Val(Right([ParObd1], 2)) + 1, 1)) End Function Public Function KalDnyYr(ParObd2 As String) As Integer 'Funkce pro výpočet počtu kalendářních dnů v daném roce KalDnyYr = DateDiff("d", DateSerial(Left([ParObd2], 4), 1, 1), DateSerial(Val(Left([ParObd2], 4)) + 1, 1, 1)) End Function Public Function KalDnyPer(PerMin, PerMax As String) As Integer 'Funkce pro výpočet počtu kalendářních dnů v daném intervalu If Right(PerMax, 2) = "12" Then KalDnyPer = DateDiff("d", DateSerial(Left([PerMin], 4), Val(Right([PerMin], 2)), 1), DateSerial(Val(Left([PerMax], 4)) + 1, 1, 1)) Else KalDnyPer = DateDiff("d", DateSerial(Left([PerMin], 4), Val(Right([PerMin], 2)), 1), DateSerial(Left([PerMax], 4), Val(Right([PerMax], 2)) + 1, 1)) End If End Function Function DnyBezSoNe(ParObd3 As String) As Integer Dim LTotalDays, LSaturdays, LSundays As Integer StartDate = DateSerial(Left(ParObd3, 4), Val(Right(ParObd3, 2)), 1) If Right(ParObd3, 2) = "12" Then EndDate = DateSerial(Val(Left(ParObd3, 4)) + 1, 1, 1) - 1 Else EndDate = DateSerial(Left(ParObd3, 4), Val(Right(ParObd3, 2)) + 1, 1) - 1 LTotalDays = DateDiff("d", StartDate - 1, EndDate) LSaturdays = DateDiff("ww", StartDate - 1, EndDate, 7) LSundays = DateDiff("ww", StartDate - 1, EndDate, 1) DnyBezSoNe = LTotalDays - LSaturdays - LSundays End Function Function DnyBezSoNeFY(ParObd4 As String) As Integer Dim LTotalDays, LSaturdays, LSundays As Integer StartDate = DateSerial(Val(Left(ParObd3, 4)), 1, 1) EndDate = DateSerial(Val(Left(ParObd3, 4)) + 1, 1, 1) - 1 LTotalDays = DateDiff("d", StartDate - 1, EndDate) LSaturdays = DateDiff("ww", StartDate - 1, EndDate, 7) LSundays = DateDiff("ww", StartDate - 1, EndDate, 1) DnyBezSoNeFY = LTotalDays - LSaturdays - LSundays End Function Public Function PrumerProNahrady(ActPer, Loc, Oscis, Kateg As String) As Currency Dim ActQtr As String PrumerProNahrady = 0 If Val(Left(DLookup("ValText", "Parameters", "[Parameter]= " & "'" & "ReportPeriod" & "'"), 4)) - Val(Left([ActPer], 4)) <= -2 Then ActQtr = Left([ActPer], 4) & "Q4" Else ActQtr = Format(DateSerial(Left([ActPer], 4), Val(Right([ActPer], 2)), 15), "yyyy\Qq") End If PrumerProNahrady = DLookup("PrumNahr", "05_02PrumNahrQtrFinQ", "[Par]= " & "'" & Loc & Oscis & Kateg & ActQtr & "'") End Function Public Function NextPer(ParObd5 As String) As String If Right(ParObd5, 2) = "12" Then NextPer = Val(Left(ParObd5, 4)) + 1 & "01" Else If Val(Right(ParObd5, 2)) > 9 Then NextPer = Left(ParObd5, 4) & Val(Right(ParObd5, 2)) + 1 Else NextPer = Left(ParObd5, 4) & "0" & Val(Right(ParObd5, 2)) + 1 End If End Function Public Function CompactRepairDB(StrFileName As String) 'Funkce provádějící komprimaci a opravu externí .accdb databáze, vstupním paramatrem je název databáze ke komprimaci Dim InpPath, OutPath As String PathPar = DLookup("ValText", "Parameters", "[Parameter]= " & "'PathDB'") InpPath = PathPar & "\" & StrFileName & ".accdb" OutPath = PathPar & "\" & StrFileName & "1.accdb" DBEngine.CompactDatabase InpPath, OutPath, dbLangGeneral & ";pwd=Fnol201809fnoL", dbVersion120, ";pwd=Fnol201809fnoL" Kill InpPath Name OutPath As InpPath End Function Public Function ParPosition(OrderVal, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) 'Funkce vrátí hodnotu parametru dle pořadí parametru uvedeného v OrderVal Dim Par As Variant Par = Array(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) ParPosition = Par(Val(OrderVal) - 1) If IsNull(ParPosition) Then ParPosition = 0 End Function