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 SQL Server Lessons    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Search When Record Source is Pass Through Query
Todd Clapp 
    
13 months ago
I'm trying to set up a search on a form that has a pass through query as the Record Source but I'm confused on how to use that pass through query on the open form since it is the Record Source.

I originally used one of the old classes on searches but that is not giving me a smooth search.  

If you take your test database example and pass it the customer list filtered by FL. How can you add a search box on the customer list to search on first names.

Do I need to create a record set for the pass through query? Hope this makes sense.
Sami Shamma  @Reply  
             
13 months ago
What you need to do is to build the passthrough query SQL statement on the fly.
In the morning, I will try to find the video in which Richard shows how to do that.
Todd Clapp OP  @Reply  
    
13 months ago
Thanks Sami for the response! I did find the video for making the passthrough query SQL on the fly but will that work if you are writing the query from sql server? I need to figure that out.

I did sorta get another way to work using recordsets and I keep getting an error "The object you entered is not a valid Recordset property". This is so frustrating because I ran a test using msgbox and I can get the results I want when I type a letter into the searchbox. UGH. I need to step away for a little while.
Sami Shamma  @Reply  
             
13 months ago
Yes it will.

Show the error massage
Todd Clapp OP  @Reply  
    
13 months ago
I stripped out a lot of detail but the part where it fails is setting the recordset. That is the part I'm having a hard time grasping.

Dim conn, rs, MySQL
Dim txtSearch As String
Dim strFilter As String
Dim divID

Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.Open TempVars("ADOConnectString")

    ' Get the text entered in SearchBox
txtSearch = Me.SearchBox.Text
    
    ' Construct the dynamic filter
If txtSearch <> "" Then
   strFilter = " tblEntity.EntityCode LIKE '%" & txtSearch & "%' "
End If

' Build the SQL query incorporting the dynamic filter
MySQL = "SELECT tblEntity.EntityID, tblEntity.EntityCode, " & _
"CONCAT(tblEntity.FirstName, ' ', tblEntity.LastName) AS DisplayName " & _
"FROM tblEntity " & _
"WHERE " & strFilter & _
"ORDER BY tblEntity.EntityCode;"
            
rs.Open MySQL, conn, 1, 3 ' 1 = keyset cursor to allow recordcount, 3 = allow modifications
    
Set Me.Recordset = rs

Sami Shamma  @Reply  
             
13 months ago
show the error massage please
Sami Shamma  @Reply  
             
13 months ago
Also, properly dim all your variables. For example,
dim rs as RecordSet.
Todd Clapp OP  @Reply  
    
13 months ago
I started over and figured it out by creating a new query on the fly and searching on that. Working fine :)

Only thing I hate about it is the cursor jump that happens when the searchTextBox gets focus and you have to find the length of the string and place the cursor at the end. Any idea how to get past that?
Sami Shamma  @Reply  
             
13 months ago
Sorry Todd, but I can't envision what you're talking about regarding the search text box. Can you please elaborate?

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

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/26/2026 2:44:06 AM. PLT: 1s