[AccessD] Can't Set Filter

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Sat Sep 17 08:40:34 CDT 2005


A.D.:

Thank you.  I am once again in your debt.  Don't think I would have ever 
spotted that <= problem.

So the message "you can't assign a value to this object"  was misleading. 
It should actually have read "You have made another dumb syntax error in 
your filter string".  Have to talk to Bill about that.

With best regards,

Rocky

----- Original Message ----- 
From: "A.D.Tejpal" <adtp at touchtelindia.net>
To: "Access Developers discussion and problem solving" 
<accessd at databaseadvisors.com>
Sent: Friday, September 16, 2005 11:03 PM
Subject: Re: [AccessD] Can't Set Filter


> Rocky,
>
>    Modified code given below, should work smoothly. Basically, there was 
> nothing wrong with your original code. The real culprit was found to be 
> use of =< instead of >= , while building up second part of filter string.
>
>    Some interesting features relevant to programmatic manipulation of 
> filtering on forms are mentioned below.
>    (a) Order of placement of Me.FilterOn statement with respect to 
> Me.Filter statement does not matter.
>    (b) Whenever statement Me.Filter = "" is used, FilterOn property of the 
> form gets automatically set to False.
>    (c) You don't have to use Me.Requery explicitly. It is redundant. 
> Application of any fresh filter condition, takes care of requery as well.
>
>    Last block of your existing code has been simplified accordingly.
>
> Best wishes,
> A.D.Tejpal
> --------------
>
> ===================================
> Private Sub SetFilter()
>    Dim strFilter As String
>
>    strFilter = ""
>    If IsDate(txtDateFilterStart) Then
>        strFilter = strFilter & "fldPMScheduleStartDate >= #" & _
>                                                txtDateFilterStart & "#"
>    End If
>
>    If IsDate(txtDateFilterEnd) Then
>        If strFilter <> "" Then strFilter = strFilter & " AND "
>        strFilter = strFilter & "fldPMScheduleEndDate <=  #" & _
>                                                txtDateFilterEnd & "#"
>    End If
>
>    Me.Filter = ""
>    If Len(strFilter) > 0 Then
>        Me.Filter = strFilter
>        Me.FilterOn = True
>    End If
> End Sub
> ===================================
>
>  ----- Original Message ----- 
>  From: Rocky Smolin - Beach Access Software
>  To: AccessD at databaseadvisors.com
>  Sent: Saturday, September 17, 2005 03:49
>  Subject: [AccessD] Can't Set Filter
>
>
>  Dear List:
>
>  Can anyone see why the following code should generate the error 2448 - 
> you can't assign a value to this object in the line Me.Filter = strFilter?
>
>  Private Sub SetFilter()
>
>  Dim strFilter As String
>
>      strFilter = ""
>      If IsDate(txtDateFilterStart) Then
>          strFilter = strFilter & "fldPMScheduleStartDate >= #" & 
> txtDateFilterStart & "#"
>      End If
>
>      If IsDate(txtDateFilterEnd) Then
>          If strFilter <> "" Then strFilter = strFilter & " AND "
>          strFilter = strFilter & "fldPMScheduleEndDate =< #" & 
> txtDateFilterEnd & "#"
>      End If
>
>      If strFilter = "" Then
>          Me.Filter = ""
>          Me.FilterOn = False
>      Else
>          Me.Filter = strFilter
>          Me.FilterOn = True
>      End If
>
>      Me.Requery
>
>  End Sub
>
>
>  MTIA,
>
>  Rocky
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list