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

Filtering a form

Status
Not open for further replies.

maxxev

Technical User
Jul 17, 2008
139
NL
Hi, i'm using an interenal filter (i.e. i'm filtering in the form rather than filtering a subform in a form)

using the following code:

Code:
Private Sub Combo38_AfterUpdate()
Me.Filter = "[Project Status] = " & Me.Combo38
Me.FilterOn = True
Me.Text36 = "Filtered"
End Sub

I have done this twice before in the same form on different fields with no issues, however they both run with auto-numbers.

The code above is an identicle copy of the correctly working codes but with the field [Project Status].

Project status contains 3 values all pulled from a table with only one column ("In development", "Cancelled" and "Completed").

To clarify; the filtering does work, but when you select the value in combo38 it comes up with a message box asking you what the value of a selected term is (enter parameter value, if I type in one of the three options the form filters fine).

Is it because they are text values, or do I have to do something else because I left a space in the name [Project Status]?

Cheers
 
It is because you are missing quotes. Text values need single quotes.


Me.Filter = "[Project Status] = '" & Me.Combo38 & "'"


As an aside, it is always best to give controls meaningful names at a very early stage. You will thank yourself later.

 
Thank you very much, works like a charm :)

I should get into the habit of re-naming things, but I've got some generic macros that work on more than one form with the same named combos now, so I'll remember to do it next time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top