Form Filter coding

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?
 
G

Guest

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) & "'"
 
G

Guest

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?
 
G

Guest

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?
 
G

Guest

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?
 
G

Guest

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?
 

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