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 
Filter or Find Records
Peter Yates 
     
13 months ago
Help!
I have a fairly simple database, just for my personal use. It’s function is to replace my paper filing cabinets. The main table is “DocsT” table. Fields in that table include “DocLocation” . Using RRs techniques, I scan all my paper filing as jpeg images in a File Folder  named “Images” under the trusted folder holding the database. I give each jpeg a relevant short name and enter that name in another field  “DocName” and using Richard’s techniques a simple press of a “Button” concatenates that file name with the full file location and the file terminator “.jpeg” and HeyPresto the image appears in the main form “DocsF”
“DocsF”, apart from the Image and other stuff like the date and destruction date, I have mimicking my old filing cabinets. So I have two other tables “DrawerT” and  “FileT”. Fields in those tables hold the names, so “DrawerName” has only a few entries like Personal, Finance. Household, Businesses, and “FileName in the “FileT” table is quite a long list, one for each file obviously, like my Banks, Barclays, Nationwide, and Household files like Electricity, Water, Repairs etc etc.
I’ve used cascading Combo Boxes on “DocsF” to mark up each image, so for example filing a Barclays Bank Statement I can simply select “Finance” in the “DrawerCombo” which by cascading means I can only then choose “Barclays” from the “FileCombo”. I’ve chosen this example because they happen to have an ID number 1 in both the “DrawerT” and the “FileT”.
This all works really well.
My problem is that I would like a search box so that I can just enter “Barclays” (or of course perhaps even “Ba”), and at the press of a button filter the form or Do.Cmd OpenForm etc just opens all the records where “Barclays”  appears as “FileCombo” entry for each and every image record.
Using Copilot, I have an unbound text box to enter the search criteria “Barclays” or just “Ba”, and a button with the “OnClick” containing the following code, using a RecordSet as the method.

DetailsPrivate Sub FindBtn_Click()
    'Declare Variable
        Dim db As DAO.Database
        Dim rst As DAO.Recordset
        Dim strSQL As String
            'Set the Current Database
        Set db = CurrentDb
    'Create SQL query to find matching records
        strSQL = "SELECT * from FileT WHERE FileName in (SELECT FileCombo from FileT)"
        'Open the Recordset
        Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)
    
    'Check if any records are found
        If rst.EOF Then
        MsgBox "NO Matching Records Found.", vbInformation
    Else
        MsgBox "Matching Records Found!", vbInformation
   'Optionally you can move through the records
        Do Until rst.EOF
            Debug.Print "Record Found: " & rst!FileName
        Loop
    End If
      'Close the recorset
        rst.Close
        Set rst = Nothing
        Set db = Nothing
End Sub


This currently produces an error at the line
Set rst = db.OpenRecordset(strSQL, dbOpenSnapshot)
Saying too few parameters. Expected 1
Any ideas?
Sandra Truax  @Reply  
         
13 months ago
One thing is you're not calling rst.MoveNext inside your Do Until rst.EOF loop.
Sandra Truax  @Reply  
         
13 months ago
Try this.

strSQL = "SELECT * FROM FileT WHERE FileName like """ & FileCombo & """"

Are you storing the actual value, or are you storing and ID that is an Autonumber?
Kevin Robertson  @Reply  
          
13 months ago
Is FileCombo a field in FileT? Sounds like it could be a Combo Box on your form.

If it is a Combo Box:
strSQL = "SELECT * FROM FileT WHERE FileName=""" & FileCombo & """"
Kevin Robertson  @Reply  
          
13 months ago
Sandra You beat me to it. LOL
Sandra Truax  @Reply  
         
13 months ago
Kevin How did that happen! You're like superman, faster than a speeding bullet, with your replies. LOL
Sami Shamma  @Reply  
             
13 months ago
Sandra Truax I can't tell you how many times this happens to me with Kevin

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/6/2026 11:25:14 AM. PLT: 1s