Hi, I would like to search between to text fields. [AbsenceFrom] and [AbsenceTo]
The code is
Option Compare Database
Private Sub Befehl21_Click()
Call Search
End Sub
Sub Search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.DateFrom) Or IsNull(Me.DateTo) Then
MsgBox "Please Enter Date Range", vbInformation, "Date Range Required"
Me.DateFrom.SetFocus
Else
strCriteria = "([AbsenceFrom] >= #" & Me.DateFrom & "# AND [AbsenceTo] <= #" & Me.DateTo & "#)"
task = "select * from Tabelle1 where (" & strCriteria & ") order by [AbsenceFrom]"
DoCmd.ApplyFilter task
End If
End Sub
I always receive an error with the dates. attached is the database with the code
Help would be awesome so I understand what is going wrong. I am new in VBA
The code is
Option Compare Database
Private Sub Befehl21_Click()
Call Search
End Sub
Sub Search()
Dim strCriteria, task As String
Me.Refresh
If IsNull(Me.DateFrom) Or IsNull(Me.DateTo) Then
MsgBox "Please Enter Date Range", vbInformation, "Date Range Required"
Me.DateFrom.SetFocus
Else
strCriteria = "([AbsenceFrom] >= #" & Me.DateFrom & "# AND [AbsenceTo] <= #" & Me.DateTo & "#)"
task = "select * from Tabelle1 where (" & strCriteria & ") order by [AbsenceFrom]"
DoCmd.ApplyFilter task
End If
End Sub
I always receive an error with the dates. attached is the database with the code
Help would be awesome so I understand what is going wrong. I am new in VBA