Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Search Button    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
2 Search Button issues
Peter Golemme 
       
2 years ago
Hello Richard and crew. Using Access 2019, I added a search button and Open Form button to my contacts list, using the techniques described in Richard's YouTube sessions. Overall they work beautifully, EXCEPT:
1. SEARCH BUTTON: IF the field happens to be empty and I click on the search button, i get a message: "Run-time error 94: Invalid use of Null".

2. OPEN FORM BUTTON:If I click on the Open Form button for a name that has an apostrophe, I get a "Syntax error - missing operator" Error 3075. My amateur diagnosis is that it is using single quotes as a delimiter, so the apostrophe is looking like an unmatched single quote.  in the "Macro Single Step Box" it shows the argument as using single Quotes for the searched field name. But as far as I can tell, my macro language uses double quotes to denote the searched field. Any thoughts or solution to this?  
Thank you
Adam Schwanz  @Reply  
           
2 years ago
1. Add a check before running the code, something like
If IsNull(FieldName) or FieldName="" Then Exit Sub

2. What is the code for this button? Is it trying to open it based on the name instead of the ID?
Peter Golemme OP  @Reply  
       
2 years ago
1.  thank you Adam for getting back to me so promptly.  I inserted your line of code at the top, and it stopped the error message. And then it simply exits the search, as instructed.  Is there a way to modify this so that it does not exit, and then simply lets me enter a search term, even though the field I click on is blank? as long as the filed has text in it, it executes the search perfectly. Of course I should aspire not to have blank fields in this column but every now and then I  do and would like to search my way out of one...  

Here's the whole Code statement, WITHOUT your addition:

Private Sub SearchProjectBtn_Click()
    
    Dim S As String
    S = InputBox("Enter Project", "Project", Project)
    If S = "" Then Exit Sub
    Me.Filter = "Project LIKE ""*" & S & "*"""
    Me.FilterOn = True
    
End Sub
Peter Golemme OP  @Reply  
       
2 years ago
2.  re: the Apostrophe problem:  I'm using an "OpenForm on click" button.

the WHERE CONDITION = is this:
="[Project]=" & "'" & [ProjectName] & "'"
Adam Schwanz  @Reply  
           
2 years ago
1. I don't think I understand what your saying. Why would you click the search button to search what is in the field if there was nothing in the field? Or are you wanting a way to search for records with no data in the field, and to use an empty search text box + the button to do that?

2. I'm not used to macros so change it to VBA, delete the macro and select code editor instead.
DoCmd.OpenForm "FormName",,,"Project=""" & [ProjectName] & """"
Peter Golemme OP  @Reply  
       
2 years ago
Re: point #1. Sorry, I may not be using precise terminology, still being somewhat new to this.  ( I am systematically going through Richard's beginner course, but every now and then jump to one of his YouTube's for a specific thing - such as the search button-- that I haven't encountered yet in my courses.)  
So, no, I am not searching for No-Data fields, and I am not trying to search within the blank field itself.  my intention, at least, was to search THAT FIELD across the WHOLE TABLE and find a match for what I put in the text box that pops up when I click the search button.

so basically, I have a continuous form that lists all my Projects by name only.  I installed the search button next to the ProjectName field in my continuous form, with the intention of its being able to search the whole Project Table, as a way of helping me jump quickly to a particular record -- i.e. a record where the field name matches what I put in the box that pops up when I click on the search button.   [Perhaps I should have simply put it in the header of my Project list form, rather than next to every single item in the list?]  

There are always a few fields where the ProjectName is blank, usually through an error or incomplete entry in the table.  I've been reluctant to simply delete them until I get to explore the Table itself.  But the blanks happen to sort to the top of my continuous form, so I end up wanting to click my search button when it is next to one of the blank ProjectName fields, so I can find the record I am looking for. If I do that from the Button next to a blank field, I get rebuked by the error message.  But if I click the Button when it's next to a field with data, it opens a box, allows me to enter the name of the record I'm looking for, and it takes me right to it.  

I can easily work around this, either by scrolling to a field with data, or by entering token data, such as an X in the blank field name.  And your fix (thank you) at least makes the Rebuke message go away.  But it just bugs me that I'm not getting it to work the way I want!
Richard Rost  @Reply  
          
2 years ago
The simple solution is to not allow project names to have ' in them. Just look at most airlines. When you book a flight, they don't allow ' in last names. My fiance's name is "D'Angelo" and it's ALWAYS a problem. LOL
Peter Golemme OP  @Reply  
       
2 years ago
sorry I think I'm using "field name" improperly.  what I mean  is the TEXT ENTRY in that particular field.  so for example, I'm next to a ProjectName that happens to be blank, and I want to find a Project named "Jones Appeal".  My intention was that I could simply click on that Search Button, enter "Jones Appeal" in the search's text box, and the form would jump to the Project named Jones Appeal (there are a few hundred projects in the list, so that's a lot quicker than scrolling).  Hopefully that's clear?! thanks again for your guidance.
Peter Golemme OP  @Reply  
       
2 years ago
thanks for your comment Richard, I guess I could go that route (banishing apostrophe's) without too much difficulty.  But here's why I didn't think I had to settle for that:  The Search button (though it's causing me the other minor problem #1 I'm discussing above) doesn't have any trouble with apostrophe's.  It's only the "Open Project" button that balks at them (problem #2).  Maybe it's because I'm using LIKE for the Search Button, but that's not an option with the Open Project button? (Since I want it to open the exact project named in the field?) Perhaps the LIKE allows it to ignore the objectionable apostrophe?

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

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 3:50:47 PM. PLT: 1s