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 Search Template    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Search Function Not Doing Anything
Bryan Findley 
     
15 months ago
I believe that I have entered all of the code correctly for the search functions (kinda hard to screw up copy and paste).  However, when I enter a value into one of the search fields, it does not change the table at all.  Doesn't matter if I hit enter or tab after making an entry.  It just sits there.  All of the sort functions are working correctly.

Thanks,
Bryan
Kevin Robertson  @Reply  
          
15 months ago
I am assuming you have a Sub Routine that handles the search. Have you called that Sub in the After Update event of your search fields?
Bryan Findley OP  @Reply  
     
15 months ago
Yes, I first copied in all the code in step 4 which I understand to be the actual search code.  I then put in the "ChangeFilter" in the AfterUpdate for each of the individual search boxes.  And the search box titles have all been name with the appropriate "Filter" tag.
Bryan Findley OP  @Reply  
     
15 months ago
I have noticed that every time I put in the following line "    If WhereStr <> "" Then WhereStr = WhereStr & " " & AndOrCombo & " "
    WhereStr = WhereStr & S", it changes the AndOrCombo to ANDORCOMBO.  Not sure if that is an issue or not.
Kevin Robertson  @Reply  
          
15 months ago
Message Box the SQL at the bottom of the sub. This will show you the SQL statement that is being built.
You may have simply missed a space. That has happened to me in the past.
Bryan Findley OP  @Reply  
     
15 months ago
Thank you Kevin,

First which sub should I put the message box in?  Would that be for after update event or in the initial search code?  Also what is the command to message box the sql.  I know Richard covered that in one of the videos that I watched early on but I've not used it since.
Kevin Robertson  @Reply  
          
15 months ago
At the end of the search code.

if the variable is mySQL
    MsgBox mySQL

MsgBox
Bryan Findley OP  @Reply  
     
15 months ago
I placed it right before the "End Sub" and it came back with a VBA error, "Compile Error: Variable Not Defined"
Kevin Robertson  @Reply  
          
15 months ago
What is the variable you are using? mySQL was just an example.
Kevin Robertson  @Reply  
          
15 months ago
Just downloaded the Template to have a look. It looks like the variable is S.

Private Sub RequeryForm()
    
    Dim S As String
    
    ' errorhandling code
    
    S = "SELECT * FROM CustomerT"
    ' other code
    Me.RecordSource = S

    MsgBox S
    
End Sub


I like to also add a space to the end of the SQL statement (S)
    S = "SELECT * FROM CustomerT "
Bryan Findley OP  @Reply  
     
15 months ago
Thank you Kevin,

That did send back an error for me.  I'm having this use my TestEquipt table.  I added the msgbox as you kindly showed me.  

Private Sub RequeryForm()
    
    Dim S As String
    
    ' errorhandling code
    
    S = "SELECT * FROM TestEquipt"
    ' other code
    Me.RecordSource = S

    MsgBox S
    
End Sub

I saved the code, saved the form, closed the form, and reopened.  As soon as I clicked on the button to open the form, I got a message box stating "Select * from TestEquipt ORDER BY NOT IsNull(TestEquipID), TestEquipID.  The TestEquipID is my autonumber (primary key) field.  There is always a value in that field.
Kevin Robertson  @Reply  
          
15 months ago
Yes. That's what was expected. What does it say when you filter the form?
Bryan Findley OP  @Reply  
     
15 months ago
I entered a number "3" in the search box as I do have an ID 3 in that table.  It came back with "Select * from TestEquipt=3 ORDER BY NOT IsNull(TestEquipID), TestEquipID
Kevin Robertson  @Reply  
          
15 months ago
It's not getting the WHERE condition (WhereStr).
Check the ChangeFilter Sub.
Also check the names of your search fields. Do they have the correct suffix?
Bryan Findley OP  @Reply  
     
15 months ago
Kevin, I double checked that all the names were right, and I recopied and pasted the If WherStr line from that sub and it worked.  Thank you so much for all of your help.  I greatly appreciate it!

Bryan
Kevin Robertson  @Reply  
          
15 months ago
You're welcome. Glad you got it fixed :)

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

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: 4/30/2026 10:33:19 AM. PLT: 0s