0
Using Queries within Microsoft Access VBA
Course Title |This is the slide title
Create Query
Delete Query
Modify Query

Pa...
Create Queries in Access This is theVBAtitle
Course Title | with slide
Create Query
Create Query
Delete Query
Modify Query...
Create Queries in Access This is theVBAtitle
Course Title | with slide
Create Query
Create Query
Delete Query
Modify Query...
Create Queries in Access This is theVBAtitle
Course Title | with slide
Create Query
Create Query
Delete Query
Modify Query...
Deleting a Query in VBA Access slide title
Course Title |This is the
Create Query
Delete Query
Delete Query

We can also u...
Deleting a Query in VBA Access slide title
Course Title |This is the
Create Query
Delete Query
Delete Query
Modify Query

...
Modify a Query in VBA Accessthe slide title
Course Title |This is
We can change the SQL in an Access query by using the SQ...
Modify a Query in VBA Accessthe slide title
Course Title |This is - Execute
Create Query
Delete Query
Modify Query
Modify ...
Creating parameters in a QueryDef by using code

Course Title |This is the slide title

If we want to create parameters in...
Create Table Structures

Course Title |This is the slide title

Create Query
Delete Query
Modify Query

Parameters
Create ...
Create Table Structures

Course Title |This is the slide title

Create Query
Delete Query
Modify Query

Parameters
Create ...
Create Table - Data Definition DDL

CourseAccess supports Data Definition Language (DDL) instructions, which
Title |This i...
Create Table – List Tables

Course Title |This is the slide title

The TableDefs collection contains Table Definition obje...
Thank you / Merci / Gracias the slide title
Course Title |This is
Create Query
Delete Query
Modify Query

Parameters
Creat...
Upcoming SlideShare
Loading in...5
×

Using Queries within Microsoft Access VBA

764

Published on

Often, users or students ask me this question: How difficult is it too learn VBA Access?
Here my answer, I did an overview: manipulating tables and queries in Microsoft Access using VBA

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
764
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
40
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Using Queries within Microsoft Access VBA"

  1. 1. Using Queries within Microsoft Access VBA Course Title |This is the slide title Create Query Delete Query Modify Query Parameters Create Table Antonio Soto http://www.ithelp4u.ca/en/ jsoto2000@gmail.com SOFTWARE ENGINEER, MCT, MCP, MCDBA, MCAD
  2. 2. Create Queries in Access This is theVBAtitle Course Title | with slide Create Query Create Query Delete Query Modify Query Parameters Create Table SQL queries in Access are an essential tool for allowing the user to view and update data. In a relational database, it is very rare to obtain meaningful data from a single table. Queries join tables together, or they can be used to update, delete, or append records. When a form is being used, it is sometimes useful to either create a new query to do something specific or to change the SQL to adapt to changes that the user is making. www.ithelp4u.ca/en 2
  3. 3. Create Queries in Access This is theVBAtitle Course Title | with slide Create Query Create Query Delete Query Modify Query Parameters Create Table www.ithelp4u.ca/en 3
  4. 4. Create Queries in Access This is theVBAtitle Course Title | with slide Create Query Create Query Delete Query Modify Query Parameters Create Table Inside the Database object, you will find the QueryDefs collection. This collection holds all the queries in your application. www.ithelp4u.ca/en 4
  5. 5. Deleting a Query in VBA Access slide title Course Title |This is the Create Query Delete Query Delete Query We can also use VBA to delete queries from the QueryDefs collection. Modify Query Parameters Create Table We can see what is in this collection by looking at your queries within the Navigation pane of Access. The QueryDefs collection reflects exactly what appears in the pane. www.ithelp4u.ca/en 5
  6. 6. Deleting a Query in VBA Access slide title Course Title |This is the Create Query Delete Query Delete Query Modify Query Parameters Create Table √ Objects created in code are not automatically refreshed in the Navigation window until you execute the RefreshDatabaseWindow command. www.ithelp4u.ca/en 6
  7. 7. Modify a Query in VBA Accessthe slide title Course Title |This is We can change the SQL in an Access query by using the SQL property of the query definition. Create Query Delete Query Modify Query Modify Query Parameters Create Table www.ithelp4u.ca/en 7
  8. 8. Modify a Query in VBA Accessthe slide title Course Title |This is - Execute Create Query Delete Query Modify Query Modify Query Parameters Create Table We can construct the SQL in program code and then execute the code by using either CurrentDB.Execute strSQL or DoCmd.RunSQL strSQL. The CurrentDb.Execute() method offers many advantages over RunSQL. Trappable Errors, a Count of affected records, as well as no warning dialogs regardless of the SetWarnings setting. The best advantage is the ability to trap and handle errors in the SQL processing: something that you can't do with DoCmd.RunSQL. To enable this, use the dbFailOnError option when executing the statement: CurrentDb.Execute "DELETE * FROM MyTempTable", dbFailOnError This redirects any errors encountered by Jet to your procedures error handler. www.ithelp4u.ca/en 8
  9. 9. Creating parameters in a QueryDef by using code Course Title |This is the slide title If we want to create parameters in program code, we do this in the SQL Create Query Delete Query Modify Query Parameters Parameters Create Table www.ithelp4u.ca/en 9
  10. 10. Create Table Structures Course Title |This is the slide title Create Query Delete Query Modify Query Parameters Create Table Create Table  As your Access application is running, there may be a need to create a table on-the-fly or amend a table structure. For example, you may be importing data into a table from a text file. If for any reason the data in the field in the text file is too large for the field in your table, it will be truncated and data will be lost.  You may also wish to create a table for a specific operation, do that operation, and then delete the table.  You can also change the properties of each individual field, such as whether it is a required field or whether it is indexed. www.ithelp4u.ca/en 10
  11. 11. Create Table Structures Course Title |This is the slide title Create Query Delete Query Modify Query Parameters Create Table Create Table www.ithelp4u.ca/en 11
  12. 12. Create Table - Data Definition DDL CourseAccess supports Data Definition Language (DDL) instructions, which Title |This is the slide title is part of the SQL Standard. Create Query Delete Query Modify Query Parameters Create Table Create Table www.ithelp4u.ca/en 12
  13. 13. Create Table – List Tables Course Title |This is the slide title The TableDefs collection contains Table Definition objects; these are all the physical tables, linked tables, and system tables in the Access database. The following code lists all of the tables and linked tables in the database: Create Query Delete Query Modify Query Parameters Create Table Create Table www.ithelp4u.ca/en 13
  14. 14. Thank you / Merci / Gracias the slide title Course Title |This is Create Query Delete Query Modify Query Parameters Create Table 14
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×