Form Filter coding

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

Guest

I have the the following code behind the after change event of a combo box:

Private Sub Combo50_Change()
Me.Filter = "MonthEnd=" & Me!Combo50
Me.FilterOn = True
DoCmd.Requery
End Sub

The row source for Combo50 and [MonthEnd] is the same.

For some reason, when I select something in the combo box, I get no results
no matter which month I select. Is there a problem with the above code or is
it something else?
 
In which clumn in the rowsource of the combo the month apear, if it is the
second column, then you need to write

Me.Filter = "MonthEnd=" & Me!Combo50.column(1)

When you the column number is not specified, it will automatically will take
the first column
======================================
If the month is text, then it should be like that
Me.Filter = "MonthEnd='" & Me!Combo50.column(1) & "'"
 
Thanks for the reply,

There's only 1 column being pulled as a row source for the Combo box so, I
assuming it doesn't need to be specified. The month is not text though, it's
a date such as 8/31/05. Could that be the issue?

Ofer said:
In which clumn in the rowsource of the combo the month apear, if it is the
second column, then you need to write

Me.Filter = "MonthEnd=" & Me!Combo50.column(1)

When you the column number is not specified, it will automatically will take
the first column
======================================
If the month is text, then it should be like that
Me.Filter = "MonthEnd='" & Me!Combo50.column(1) & "'"

--
I hope that helped
Good luck


Bdavis said:
I have the the following code behind the after change event of a combo box:

Private Sub Combo50_Change()
Me.Filter = "MonthEnd=" & Me!Combo50
Me.FilterOn = True
DoCmd.Requery
End Sub

The row source for Combo50 and [MonthEnd] is the same.

For some reason, when I select something in the combo box, I get no results
no matter which month I select. Is there a problem with the above code or is
it something else?
 
In that case try this

Me.Filter = "MonthEnd=#" & Me!Combo50.column(1) & "#"

--
I hope that helped
Good luck


Bdavis said:
Thanks for the reply,

There's only 1 column being pulled as a row source for the Combo box so, I
assuming it doesn't need to be specified. The month is not text though, it's
a date such as 8/31/05. Could that be the issue?

Ofer said:
In which clumn in the rowsource of the combo the month apear, if it is the
second column, then you need to write

Me.Filter = "MonthEnd=" & Me!Combo50.column(1)

When you the column number is not specified, it will automatically will take
the first column
======================================
If the month is text, then it should be like that
Me.Filter = "MonthEnd='" & Me!Combo50.column(1) & "'"

--
I hope that helped
Good luck


Bdavis said:
I have the the following code behind the after change event of a combo box:

Private Sub Combo50_Change()
Me.Filter = "MonthEnd=" & Me!Combo50
Me.FilterOn = True
DoCmd.Requery
End Sub

The row source for Combo50 and [MonthEnd] is the same.

For some reason, when I select something in the combo box, I get no results
no matter which month I select. Is there a problem with the above code or is
it something else?
 
Without the column number
--
I hope that helped
Good luck


Bdavis said:
Thanks for the reply,

There's only 1 column being pulled as a row source for the Combo box so, I
assuming it doesn't need to be specified. The month is not text though, it's
a date such as 8/31/05. Could that be the issue?

Ofer said:
In which clumn in the rowsource of the combo the month apear, if it is the
second column, then you need to write

Me.Filter = "MonthEnd=" & Me!Combo50.column(1)

When you the column number is not specified, it will automatically will take
the first column
======================================
If the month is text, then it should be like that
Me.Filter = "MonthEnd='" & Me!Combo50.column(1) & "'"

--
I hope that helped
Good luck


Bdavis said:
I have the the following code behind the after change event of a combo box:

Private Sub Combo50_Change()
Me.Filter = "MonthEnd=" & Me!Combo50
Me.FilterOn = True
DoCmd.Requery
End Sub

The row source for Combo50 and [MonthEnd] is the same.

For some reason, when I select something in the combo box, I get no results
no matter which month I select. Is there a problem with the above code or is
it something else?
 
Perfect. Thanks

Ofer said:
Without the column number
--
I hope that helped
Good luck


Bdavis said:
Thanks for the reply,

There's only 1 column being pulled as a row source for the Combo box so, I
assuming it doesn't need to be specified. The month is not text though, it's
a date such as 8/31/05. Could that be the issue?

Ofer said:
In which clumn in the rowsource of the combo the month apear, if it is the
second column, then you need to write

Me.Filter = "MonthEnd=" & Me!Combo50.column(1)

When you the column number is not specified, it will automatically will take
the first column
======================================
If the month is text, then it should be like that
Me.Filter = "MonthEnd='" & Me!Combo50.column(1) & "'"

--
I hope that helped
Good luck


:

I have the the following code behind the after change event of a combo box:

Private Sub Combo50_Change()
Me.Filter = "MonthEnd=" & Me!Combo50
Me.FilterOn = True
DoCmd.Requery
End Sub

The row source for Combo50 and [MonthEnd] is the same.

For some reason, when I select something in the combo box, I get no results
no matter which month I select. Is there a problem with the above code or is
it something else?
 
Back
Top