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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

filtering recordset with combobox

Status
Not open for further replies.

hedgracer

Programmer
Mar 21, 2001
186
US
I have a combobox which has the following under the RowSource property:

SELECT DISTINCTROW Onyx_Allocation.Month FROM Onyx_Allocation GROUP BY Onyx_Allocation.Month ORDER BY Onyx_Allocation.Month;

There is only one column in the combobox which is populated with data from the month column of the Onyx_Allocation table. The data is as follows:

01/31/2010
02/28/2010

I have the following code under the AfterUpdate in the combobox:

Private Sub cboMthSelection_AfterUpdate()

Me.Form.Filter = "[Month] = '" & Me.cboMthSelection & "'"
Me.Form.FilterOn = True


End Sub

The problem is that when I select 01/31/2010 one or two rows of 02/28/2010 show up. The same thing happens when I select 02/28/2010 (one or two rows of 01/31/2010 show up). What is causing this? Any help is appreciated. Thanks.

Dave
 
If [Month] is a real Date/Time field then:
Me.Form.Filter = "[Month]=#" & Format(Me!cboMthSelection, "yyyy-mm-dd") & "#"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Month is not a real date/time field. This is a linked table. The underlying field is SQL server 2005 varchar(50).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top