can't get Filter and Order by to work ???

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my data tab
Filter "Year([chktran].[CheckDate]) >= 2004"
Order by chktran.description,chktran.CheckNumber DESC
Allow Filters Yes

Yet the form retreives all records all years and not in the order specified
Please explain ??
 
Yes You wrote the following
The Format() function returns a string value.
ry taking the Year() of the date field instead i.e.:

.Filter = "Year([chktran].[CheckDate]) >= 2004"
.FilterOn = True

It is important to set the FilterOn property at runtime as well

I Did as you said in my Data Tab and it's not working
I am not sure what you mean at run time
does .Filter = "Year([chktran].[CheckDate]) >= 2004" have to be coded
somewhere in the form and if yes where ?

Thanks for your reply
 
Try adding these 2 lines to the Open event procedure of the form, i.e.:

Private Sub Form_Open(Cancel As Integer)
Me.Filter = "Year([chktran].[CheckDate]) >= 2004"
Me.FilterOn = True
End Sub

If you still can't get that working, you could create a query that filters
and sorts as you wish, and use the query as the RecordSource of the form.
 
The filter works now ok.
But I still have a problem with order by
Me.OrderBy = "[chktran].[Description], [chktran].[CheckDate] Desc"
Does not work


Allen Browne said:
Try adding these 2 lines to the Open event procedure of the form, i.e.:

Private Sub Form_Open(Cancel As Integer)
Me.Filter = "Year([chktran].[CheckDate]) >= 2004"
Me.FilterOn = True
End Sub

If you still can't get that working, you could create a query that filters
and sorts as you wish, and use the query as the RecordSource of the form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

nach said:
Yes You wrote the following
The Format() function returns a string value.
ry taking the Year() of the date field instead i.e.:

.Filter = "Year([chktran].[CheckDate]) >= 2004"
.FilterOn = True

It is important to set the FilterOn property at runtime as well

I Did as you said in my Data Tab and it's not working
I am not sure what you mean at run time
does .Filter = "Year([chktran].[CheckDate]) >= 2004" have to be coded
somewhere in the form and if yes where ?

Thanks for your reply
 
nach said:
The filter works now ok.
But I still have a problem with order by
Me.OrderBy = "[chktran].[Description], [chktran].[CheckDate] Desc"
Does not work

There is an OrderByOn property that must be set to True in the same way
that you had to add FilterOn = True to get the filter to work.
 
Back
Top