Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Using Unbound Combo to Filter Fields
David S 
    
14 years ago
Help Please.
I have a simple database with 3 Tables, AccountT, BankAccountT and CategoryT.
I have designed a form based on AccountQ (a query containing all fields in AccountT) showing all fields, including a field called Category and another called BankAccount.
The entries for those fields are selected by a combo box.
In my footer I have two unbound combo boxes falled respectively, CategoryFilter and BankAccountFilter which take their data dource from, respectively, CategoryT and BankAccountT.
Using VBA I am trying to filter those fields in a continuous form, and the VBA I have used is:

Private Sub RequeryForm()

    Dim W As String
    Dim R As String
    Dim S As String
    
    
    W = ""
    S = " * "
    

    If Not IsNull(CategoryFilter) Then
        If W <> "" Then W = W & " AND "
        W = W & " CatID =" & CategoryFilter
    End If
    
     If Not IsNull(BankAccountFilter) Then
        If W <> "" Then W = W & " AND "
        W = W & " BankID=" & BankAccountFilter
    End If
    
    
    R = "SELECT * FROM AccountQ "
  
    If W <> "" Then R = R & " WHERE " & W
    
    
    Me.RecordSource = R

End Sub

That is called in the Afterupdate Event of each unbound combo box.

However it is not working (Access 2010 with Windows 7).

If I use, for example, the BankAccountFilter combo box, I get asked to Enter Parameter Value for BankID.  
If I click on cancel I get a run-time error '2001' you cancelled the previous operation and when I debug Me.RecordSource = R is highlighted in yellow, but when I hover over it it says Me.RecordSource = "AccountQ" and R = "SELECT * FROM AccountQ WHERE BankID=2" (assuming I have chosen the 2nd bank it always gives the right number!)
However if I enter 2 or just click on the OK nothing happens.
Where have I gone wrong?

  


Reply from Richard Rost:

Your code looks perfect. I'd have to see the database to tell you for sure what the problem is. I assume the first column in your combo boxes is the hidden ID. Aside from that, I don't see it.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/16/2026 5:47:36 PM. PLT: 1s