- Joined
- Oct 3, 2012
- Messages
- 2
- Reaction score
- 0
Hi all,
I have created a multi-search criteria form to filter records in an Access database. My filter is working well except regarding the search between two dates. I have really checked several times names and format for data, and everything appears to be consistent, but still I am getting an error “Type mismatch (Error 13)”.
I am a pure beginner with Access, and I am sure that an experienced user will find a solution straight away, hence my request!
Could anybody help with this or give some tips?!
Thank you to let me know
Franck
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Const conJetDate = "\#dd\/mm\/yyyy\#"
varWhere = Null
If Not IsNull(Me.txtStartDate) Then
varWhere = varWhere & "([Decision Date] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtEndDate) Then
varWhere = varWhere & "([Decision Date] < " & Format(Me.txtEndDate, conJetDate) & ") AND "
End If
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
End Function
I have created a multi-search criteria form to filter records in an Access database. My filter is working well except regarding the search between two dates. I have really checked several times names and format for data, and everything appears to be consistent, but still I am getting an error “Type mismatch (Error 13)”.
I am a pure beginner with Access, and I am sure that an experienced user will find a solution straight away, hence my request!
Could anybody help with this or give some tips?!
Thank you to let me know
Franck
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Const conJetDate = "\#dd\/mm\/yyyy\#"
varWhere = Null
If Not IsNull(Me.txtStartDate) Then
varWhere = varWhere & "([Decision Date] >= " & Format(Me.txtStartDate, conJetDate) & ") AND "
End If
If Not IsNull(Me.txtEndDate) Then
varWhere = varWhere & "([Decision Date] < " & Format(Me.txtEndDate, conJetDate) & ") AND "
End If
If IsNull(varWhere) Then
varWhere = ""
Else
varWhere = "WHERE " & varWhere
If Right(varWhere, 5) = " AND " Then
varWhere = Left(varWhere, Len(varWhere) - 5)
End If
End If
BuildFilter = varWhere
End Function