Maybe something like this:
Code:
Option Compare Database
Option Explicit
Private Sub cmdGetReport_Click()
On Error GoTo Err_cmdGetReport_Click
Dim stDocName As String
Dim StartDate As Date
Dim EndDate As Date
Dim ServDate As String
Const fmtDate = "\#mm\/dd\/yyyy\#"
stDocName = "Your_Report_Name" '<<<---change this to your report name
'are both dates entered?
If IsNull(tbFromDate) Or IsNull(tbToDate) Then
MsgBox "You must enter both start and end dates."
Me.tbFromDate.SetFocus
Exit Sub
ElseIf Me.tbFromDate > Me.tbToDate Then
'is end date after start date?
'automatic swapping
StartDate = Me.tbToDate
EndDate = Me.tbFromDate
' MsgBox "End date must be greater than Start date."
' Me.tbFromDate.SetFocus
' Exit Sub
Else
Me.Visible = False '<<--hides form "Statistika"
StartDate = Me.tbFromDate
EndDate = Me.tbToDate
End If
ServDate = "[Datum]" '<<--date field in table "Artikal"
'open report
DoCmd.OpenReport stDocName, acPreview, , _
Format(ServDate, fmtDate) & " Between " & _
Format(StartDate, fmtDate) & " And " & _
Format(EndDate, fmtDate)
End If
Exit_cmdGetReport_Click:
Exit Sub
Err_cmdGetReport_Click:
MsgBox Err.Description
Resume Exit_cmdGetReport_Click
End Sub