Inactive use of Null in Search form

Ronaldo9

Registered User.
Local time
Today, 17:06
Joined
Jul 20, 2011
Messages
21
Hi there,

I'm trying to add a new functionality on my search form where the user can search for records that haven't been modified(based on the field DateModified) for certain amount of time.

This is what I added in my search function but it's giving me "Invalid use of Null"

If Not IsNull(Me.txtInactiveTime) Then
Dim LValue As Integer
LValue = DateDiff("d", Me.DateModified, Date)
Select Case Me.txtInactiveTime
Case "> 1 month"
strWhere = strWhere & "(LValue >= " 30 ") AND "
Case "> 2 months"
strWhere = strWhere & "(LValue >= " 60 ") AND "
End Select
End If

txtInactiveTime is a combo box where the user chooses the time during which the records haven't been modified.(i.e. 1 month, 2 months etc.)

Any suggestion would be appreciated...
Thanks,
Elias
 
strWhere = strWhere & "(LValue >= " 60 ") AND "

probably should be:
strWhere = strWhere & "(LValue >= 60 ) AND "

The "terminates" the string which is probably causing the error
 
My guess is this line,
Code:
LValue = DateDiff("d", Me.DateModified, Date)
You need to check for Me.DateModified is null or not. Using Null value in a DateDiff function would also throw "Invalid Use of Null" error.
 
OK so now I check whether DateModified is null or not then I calculate the value of LValue using:
LValue = DateDiff("d", Me.DateModified, Date)

That got rid off the "Invalid use of Null", but now each time I run the search, it's prompting me to enter a value for LValue..
 

Users who are viewing this thread

Back
Top Bottom