Skip to Main Content
Microsoft® Access® 2010 Programmer's Reference
book

Microsoft® Access® 2010 Programmer's Reference

by Teresa Hennig, Rob Cooper, Geoffrey L. Griffith, Jerry Dennison
August 2010
Intermediate to advanced content levelIntermediate to advanced
1272 pages
32h 43m
English
Wrox
Content preview from Microsoft® Access® 2010 Programmer's Reference

Chapter 13. Using SQL with VBA

WHAT'S IN THIS CHAPTER?

  • Working with SQL strings in VBA

  • Using SQL when opening Forms and Reports

  • The ReplaceOrderByClause and ReplaceWhereClause Functions

You may be familiar with SQL; after all, it's inside every query you create. SQL (Structured Query Language) is the language of queries and Recordsets; it's how you retrieve, update, insert, and delete records in your data-base tables.

When you use the Query Design View in Access, you are actually building a SQL statement. Most of the time, you won't actually need to look at the SQL code, but you can see it using the SQL view if you're curious.

Conversely, you can take most SQL statements, paste them into the SQL view of a new query, and then switch over to Design view to see how they work. There are a few types of SQL statements for which this won't work—union queries and pass-through queries, for example, cannot be viewed using Design view.

Even if you're comfortable using SQL in queries, you may not be familiar with building SQL statements in VBA. If you're not, you're missing out! Using SQL in VBA is a powerful technique that can enable many great features in your Access applications. By using VBA, you can build custom SQL statements for combo boxes, forms, and reports. For example, you'll be able to change the sorting and selecting of records on continuous forms, control the record selection on reports, and limit the drop-down lists of combo boxes based on other combo boxes.

Let's begin by exploring ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Access™ 2007 VBA Programmer's Reference

Access™ 2007 VBA Programmer's Reference

Teresa Hennig, Rob Cooper, Geoffrey Griffith, Armen Stein
Excel® 2007 VBA Programmer's Reference

Excel® 2007 VBA Programmer's Reference

John Green, Stephen Bullen, Rob Bovey, Michael Alexander
Professional Access 2013 Programming

Professional Access 2013 Programming

Teresa Hennig, Ben Clothier, George Hepworth, Dagi Yudovich

Publisher Resources

ISBN: 9780470591666Purchase book