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 
Access SQL VBA Help
Alex Hedley 
           
15 years ago
Have you taken the new Seminar on SQL [http://www.599cd.com/site/courselist/seminars/access-sql/]
It's excellent! I'd advise it very much as it will help with your question.

So lets first break down the SQL Statement:-

SELECT

PROIDNO, PROCLIDNO, PROCLNAME, PROPADDR1, PROPADDR2, PROPSTATE, PROPZIP, PROIT2, PROUD22, PROUD23, PROUD24, *

Are there more than 11 fields in that table?

The * means select all the fields from the table, but you have selected some fields before this, are both necessary?

FROM STKLKP
This is the name of the table you are getting the data from.


WHERE (((STKLKP.PROIDNO) Like IIf(IsNull([Forms]![fdlgSelect]![Number]),"*",[Forms]![fdlgSelect]![Number])) AND ((STKLKP.PROCLNAME) Like IIf(IsNull([Forms]![fdlgSelect]![Client]),"*",[Forms]![fdlgSelect]![Client])) AND ((STKLKP.PROPADDR1) Like IIf(IsNull([Forms]![fdlgSelect]![Street]),"*",[Forms]![fdlgSelect]![Street])) AND ((STKLKP.PROIT2) Like IIf(IsNull([Forms]![fdlgSelect]![Description]),"*",[Forms]![fdlgSelect]![Description])) AND ((STKLKP.PROPCITY) Like IIf(IsNull([Forms]![fdlgSelect]![City]),"*",[Forms]![fdlgSelect]![City])));

In the WHERE statement you have multiple Immediate IF functions,

an example is
  iif ([Qty] > 10, "large", "small")
which is another way or writing
  If [Qty] > 10 Then
      result = "large"
  Else
      result = "small"
  End If

So I guess you have textboxes on your form [fdlgSelect] named [Number, Client, ...]
These relate to the field names in the table you are searching

  PROIDNO -> Number, PROCLNAME -> Client, PROPADDR1 -> Street, PROIT2 -> Description, PROPCITY -> City

The WHERE is filtering through your records and if there is no value in that textbox (IsNull(Forms]![fdlgSelect]![Number])) then show all (*) else search for that value the user has entered (Forms]![fdlgSelect]![Number])

  IsNull(Forms]![FORMNAME]![FIELDNAME])

This does the same for the rest of the textboxes Client, Street etc.
It has the LIKE keyword which when joined with the *
"* allows you to match any string of any length (including zero length)"
But if not it will only match EXACTLY what the user entered.

You are joining the WHERE criteria with ANDs when you might want ORs as everything must match for that one record.

Richard answered a similar question in the forum
[http://www.599cd.com/blog/display-article.asp?ID=352&Thread=Search+++Lookup+++Display&ExpandAll=YES]

Here he advises that a comma seperated list isn't the best option.

There is a Search Seminar coming out very soon, which will be using the SQL seminars so I'd advise looking out for that after getting the SQL.

Regards
Alex

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/22/2026 2:54:27 PM. PLT: 1s