Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter by month

Status
Not open for further replies.

Jaco

Programmer
Aug 29, 2000
57
PL
Hello,

does anyone have any idea how to apply filter by month. I have a combobox containing months and after selecting for example 'january' I would like to filter records and see only the records from January.
In MS Access something like this works
rs.filter="(Format(DateField,'mmmm')='" & combo_month & "')"
but in VB it doesn't

Thanks,

Jaco
 
rs.Source = "SELECT * FROM table " & _
"WHERE DateField = " & combo_month & ""

Or something like this, don't really know without knowing what code you have for opening up the db. ----------------
Joe
 
You could try something like

"MONTH(DateField)=" & (comboBox.ListIndex + 1)

as a filter.
 
I've tried this but in seems that in the filter method you can't use functions which use fields as arguments.
e.g
rs.filter="SomeFunction(DatabaseField)=Something" is not allowed

You can use only syntax like this
rs.filter="DatabaseField=Something"

I don't understand why ist it so but for me this sux [mad]

I will have to change recordset's datasource every time I want to apply a filter.

Thanks for help anyway

Jaco
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top