Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Policz(ByVal p_dzien as String, ByVal p_nazwa as String) as Integer
  2.  
  3.  Dim a1 as DAO.Recordset
  4.  Dim a2 as DAO.Recordset
  5.  Dim a3 as DAO.Recordset
  6.  Dim a4 as DAO.Recordset
  7.  Dim nr as Integer
  8.  Dim kryt as String
  9.  Dim war1 as Integer
  10.   Dim war2 as Integer
  11.  Dim prz as Integer
  12.  Dim wynik as Integer
  13.  
  14.  Set a1 = CurrentDb.OpenRecordset("PRZEDMIOTY",DbOpenSnapshot)
  15.  
  16.  kryt = "NAZWA_PRZEDM = '"&p_nazwa
  17.  a1.FindFirst kryt
  18.    if a1.NoMatch Then
  19.  
  20.  Policz = 0
  21.  Exit Function
  22.  
  23.    Else
  24.    
  25.    Set a2 = CurrentDb.OpenRecordset("ROZKLADY",DbOpenSnapshot)
  26.    kryt = "NR_PRZEDM = '"&nr&"' AND DZIEN = '"&p_dzien
  27.  
  28.    a2.FindFirst kryt
  29.  
  30.    Do until a2.NoMatch
  31.    war1 = 1+war1
  32.  
  33.    a2.FindNext
  34.    Loop
  35.  
  36.    End if
  37.   a1.FindNext
  38.   Loop
  39.  
  40.   Set a3 = CurrentDb.OpenRecordset("PRZEDMIOTY",DbOpenSnapshot)
  41.   a3.MoveFirst
  42.   Do untila3.EOF
  43.  
  44.   prz = a3![NR_PRZEDM]
  45.   kryterium = "NR_PRZEDM = '" &prz&'" AND DZIEN = '"&p_dzien
  46.  Set a4 = CurrentDb.OpenRecordset("ROZKLADY",DbOpenSnapshot)
  47.  
  48.   a4.FindFirst kryt
  49.  
  50.   war2 = war2+1
  51.   a4.FindNext
  52.   Loop
  53.  
  54.   if war2>war1 Then
  55.   wynik = 1+wynik
  56.   End if
  57.   a3.MoveNext
  58.  
  59.   Loop
  60.  
  61.   Policz = wynik
  62.   Exit Function
  63.  
  64.   End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement