473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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
4 27737
edited initial post...couldn't find the delete option
Mar 1 '08 #2
Stewart Ross
2,545 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
32,556 Expert Mod 16PB
Check out Example Filtering on a Form and Quotes (') and Double-Quotes (") - Where and When to use them for assistance with these issues.
Mar 7 '08 #5

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

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
1
by: Alex | last post by:
Acc97. I have a form which within a subform records machine down time. I have a total of 8 machines. (1-2-3 ect.) What I have been doing is using a combo box linked to the record table to...
2
by: Luther | last post by:
I want to create a form that searches a table. The hard part is this, I'd like to have the available records filtered based on combobox selections. For example, if this were a vehicle database, I...
2
by: Sean | last post by:
Greetings all, I am attempting to make a form that will filter through several tables that (I believe) have refretial integrity. I am pulling data from several tables into the form and i would...
0
by: Jason | last post by:
I have a primary form which is used to enter/edit data in a table named Test_Results. On this primary form there is a subform which displays site addresses. This subform is linked to the primary...
1
by: MLH | last post by:
I have a form (xxxxxxxxxxxxxx) with a combo-box control (yyyyyyyyyyyyyy). The rowsource property for that combo box is as follows: SELECT DISTINCTROW ., . FROM ; The SQL for qryVehicleList...
1
by: hackerslacker | last post by:
I have an ordering form that use two combo boxes to filter down the records of a Products table. This worked fine with the after_Update of the first filtering the records and creating the...
1
by: MLH | last post by:
I have a form with a subform control on it listing records returned by a saved query named UnbilledVehicles. I would like to put command buttons on the main form to apply dynamic filters to the...
3
by: flymo | last post by:
Hello All, I've bee trying out access 2007 and have a weird issue and would like to see if I'm issing something really basic. I have a form based on a query, I create a combo to look for records...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.