ServerFilter problem - why doesn't this work?

  • Thread starter Maury Markowitz
  • Start date
M

Maury Markowitz

I have a form that displays the output from a fairly complex VIEW. In order
to keep the display time down to something reasonable, I've put two date
fields onto the screen to limit the records to ones between those two dates.
In the Form_Open I set the dates to three days in the past to three days in
the future, then use that in the ServerFilter...

Private Sub Form_Open(Cancel As Integer)
Me!FromDate = DateAdd("d", -3, Date)
Me!ToDate = DateAdd("d", 3, Date)

Me.ServerFilter = "SettleDate >= '" & Me!FromDate & "' and SettleDate <=
'" & Me!ToDate & "'"
Me.OrderBy = "SettleDate"
Me.OrderByOn = True
Me.Refresh
End Sub

This works fine, although the ordering does NOT work properly.

Anyway when the user changes the fields I want the records to change as
well. Yet the following code does nothing...

Private Sub FromDate_AfterUpdate()
Me.ServerFilter = "SettleDate >= '" & Me!FromDate & "' and SettleDate <=
'" & Me!ToDate & "'"
Me.Requery
Me.Refresh
End Sub
Private Sub ToDate_AfterUpdate()
Me.ServerFilter = "SettleDate >= '" & Me!FromDate & "' and SettleDate <=
'" & Me!ToDate & "'"
Me.Requery
Me.Refresh
End Sub

It looks the same to me, so why does it work the first time and then not
from then on?

Maury
 
D

david epsom dot com dot au

There are a number of situations in which Access fails
to notice that there has been a change to SQL. This may
be one of them. The initial change is noticed: the
second change (which is only a change to the /parameters/
in the filter) is not. It may be that the parameter
change has been 'optimised out'. As a test, you may wish
to try removing the filter before changing it (I realise
this would defeat the point of the exercise). You might
also try to get a record count after applying the new
filter: in Access, that sometimes forces the system to
requery, even when .requery is ignored.

I'm sorry that I don't actually know anything about
server filters: these are just suggestions.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top