If IsNothing - Help Please

delamerbleu

Registered User.
Local time
Today, 10:42
Joined
Nov 27, 2005
Messages
15
I am working on a query form, which allow users to set filter parameters. The parameters are: KeywordsEN, KeywordsCN, NewsSource, DateFrom, and Date To. If nothing in the field, the filter will skept this filter option. Below is my code, which is adapted from one of early posting (very very helpful!). But there indicate an error on the "If isnothing", pls kindly help

'OK Move on and build Searchstring
Dim Searchstr As String

If Not IsNothing(KeywordsEN) Then Searchstr = "[KeywordsEN]= " & Chr$(34) & Me!KeywordsEN & Chr$(34)

If Not IsNothing(KeywordsCN) Then
If IsNothing(Searchstr) Then
Searchstr = "[KeywordsCN]= " & Chr$(34) & Me!KeywordsCN & Chr$(34)
Else
Searchstr = Searchstr & " AND [KeywordsCN]= " & Chr$(34) & Me!KeywordsCN & Chr$(34)
End If
End If

If Not IsNothing(NewsSource) Then
If IsNothing(Searchstr) Then
Searchstr = "[NewsSource]= " & Chr$(34) & Me!NewsSource & Chr$(34)
Else
Searchstr = Searchstr & " AND [NewsSource]= " & Chr$(34) & Me!NewsSource & Chr$(34)
End If
End If

If Not IsNothing(DateFrom) Then
DateFrom = Format(DateFrom, "mm/dd/yy")
DateTo = Format(DateTo, "mm/dd/yy")
If IsNothing(Searchstr) Then
Searchstr = "[IssueDate]>= #" & Me!DateFrom & "# AND [IssueDate]<= #" & Me!DateTo & "#"
Else
Searchstr = Searchstr & " AND [IssueDate]>= #" & Me!DateFrom & "# AND [IssueDate]<= #" & Me!DateTo & "#"
End If
End If
Me!Searchstr = Searchstr
Me![subFormQryNewsClips].Form.Filter = Searchstr
Me![subFormQryNewsClips].Form.FilterOn = True


End Sub
 
Try "If IsNull(MyVar) or MyVar = "" Then..."

IsNothing only applies to ObjectVariables, right?
 
thanks

thanks a lot! I will try it.
 

Users who are viewing this thread

Back
Top Bottom