Problems with filtering a subform

J

James Frater

Hello All,

I'm having difficulty in passing a filter through to a subform on the
click() event of a button. I've tested it out in a query adn it works
beautifully, but I jsut can't get it to work for the subform. Any thoughts?

Many thanks

James


Sub RefreshSeries()
Dim strWhere As String

strWhere = "sdate<=" & Me.txtToday & " and edate>=" & Me.txtToday

With Me.sub_Series.Form
.Filter = strWhere
.FilterOn = True
End With

End Sub
 
D

Douglas J. Steele

Assuming sdate and edate are date fields, you need to delimit the values
with # characters. You also need to ensure that the dates are formatted in a
way that Access will recognize (in many cases, Access doesn't respect the
date format specified in Regional Settings in the Control Panel):

strWhere = "sdate<=" & Format(Me.txtToday, "\#yyyy\-mm\-dd\#") & _
" and edate>=" & Format(Me.txtToday, "\#yyyy\-mm\-dd\#")
 

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