Private S As String
Private d1 As Date
Private d2 As Date
Private Sub Report_Open(Cancel As Integer)
Dim l As Long
Dim l2 As Long
On Error Resume Next
Me.emplema.Picture = Application.CurrentProject.Path & "\LogoMini.bmp"
On Error GoTo eee
d1 = InputData(DateSerial(Year(Date), Month(Date), 1), "Начало периода")
S = S & " c " & Format(d1, "dd.mm.yy")
If CLng(d1) = 0 Then
Cancel = True
Exit Sub
End If
d2 = InputData(DateAdd("m", 1, DateSerial(Year(Date), Month(Date), 1)) - 1, "Конец периода")
If CLng(d2) = 0 Then
Cancel = True
Exit Sub
End If
S = S & " по " & Format(d2, "dd.mm.yy")
l2 = InputSPR("SELECT idSpr, NameFind FROM zsprOtd", "NameFind", "idSpr", 2, "550")
If l2 <> 0 Then
S = S & VBA.vbCrLf & "" & DLookup("NameFind", "zsprOtd", "idSpr=" & l2)
End If
If l2 > 0 Then
Me.Filter = "dOtdID=" & l2 & " and " & "oplData3 >= " & Format(d1, "\#mm\/dd\/yy\#") & " and " & "oplData3 <= " & Format(d2, "\#mm\/dd\/yy\#")
Else
Me.Filter = "oplData3 >= " & Format(d1, "\#mm\/dd\/yy\#") & " and " & "oplData3 <= " & Format(d2, "\#mm\/dd\/yy\#")
End If
Me.FilterOn = True
Exit Sub
eee:
MsgBox Err.Description
End Sub |