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 
VBA vs Criterias Expressions
Tomasz Drozdzak 
   
3 years ago
I have a following question: is the VBA language syntax the same, as the Criterias Expression syntax in MS Access Query? May I use the same language in both cases, or they are two different things? Eventually, where can I find a training video, how to build the Query Criteria Expressions properly?
Kevin Yip  @Reply  
     
3 years ago
Queries use the SQL language, and program code uses VBA, so they are two different things.  SQL was invented by IBM in the 70s, while Visual Basic (predecessor of VBA) was invented by Microsoft in the 90s.

VBA is a "general-purpose" programming language, one that can be use to make different kinds of applications.  But SQL is strictly for relational database systems like Access, SQL Server, MySQL, etc.

In Access, you can use VBA expressions within SQL:

    SELECT * FROM MyTable WHERE MyDate <= Now();
    (Now is a VBA function, thus a VBA expression)

or work with SQL and queries within VBA:

    Dim r As Recordset
    Set r = CurrentDb.OpenRecordset("SELECT * FROM MyTable WHERE MyDate <= #" & Me!DateField & "#;")

In the query design screen, the expression inside the criteria box is *not* really a valid expression.  It is the actual SQL statement, shown in the SQL window, that counts.  For instance, the criteria box may let you type something like:

    =>X And <=Y

but the actual SQL criteria, as shown in the SQL window, should be:

    field1>=X And field1<=Y
Tomasz Drozdzak OP  @Reply  
   
3 years ago
Thank you very much for your comprehensive answer. You have explained to me, the intricacies of both languages in a very clear way. This is the answer for my question, I was looked for. Thanks a lot once more.

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:24:39 AM. PLT: 1s