467,146 Members | 1,287 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,146 developers. It's quick & easy.

Filtering form records using a combo box

This seems like it should be an easy thing, but I think I'm missing something simple here...or I'm just going about it all wrong...

Using Access 2003

I have a form that lists vehicle service dates for different company terminals.
The form loads showing all records.

In the form header I have a combo box named "CSCFilter" that is unbound, and uses the table/query option to list the 16 terminals in our company.

The field I'm trying to filter in the details section is named "CSC"

I'm trying to use the After Update event on the combo box to filter the form based on the selection made on the combo box.
Basically what I have now is 16 identical forms, with each one sorting the CSC manually in the SQL statement...which makes updating the form a pain because I have to make every little change 16x. I want to switch to one form, where I can cycle through the 16 terminals, simply by choosing them on the combo box.

This is what I have in the After Update event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CSCFilter_AfterUpdate()
  2. Me.Filter = "CSC = " & Me.CSCFilter
  3. Me.FilterOn = True
  4. End Sub
Using this function will get the form to filter correctly, however it's not accepting the value in the combo box as the filter value...it's spitting up a dialog box asking me to enter in the parameter value, but the dialog box is changing it's name to the name selected in the combo box...if that makes any sense.

What am I doing wrong?
Mar 1 '08 #1
  • viewed: 25245
Share:
4 Replies
edited initial post...couldn't find the delete option
Mar 1 '08 #2
Expert Mod 2GB
This seems like it should be an easy thing, but I think I'm missing something simple here......This is what I have in the After Update event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub CSCFilter_AfterUpdate()
  2. Me.Filter = "CSC = " & Me.CSCFilter
  3. Me.FilterOn = True
  4. End Sub
Hi Novoselent. Your filter is very nearly right - but you are missing some quote marks from your filter string. Without these, you are not passing a string literal to the filter. The value from the combo box is being passed as if it was a field name - and because there is no match for that field it is asking you for the parameter value.

Easy to fix - just change your Me.Filter statement to
Expand|Select|Wrap|Line Numbers
  1. Me.Filter = "CSC = '" & Me.CSCFilter & "'"
-Stewart
Mar 1 '08 #3
works like a charm!

I was physically unable to walk away last night until I had it working...so I figured out how to do it, using a macro instead...but I liked my original approach so much better, much cleaner i think. nice to know I was close at least. Those quotes get me all the time...pesky things!

Thanks for helping me get it working!
Mar 1 '08 #4
NeoPa
Expert Mod 16PB

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Alex | last post: by
2 posts views Thread by Sean | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.