How to Compile Programs on MS Access 2007

Written by jaime avelar
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Compile Programs on MS Access 2007
Learn how to compile VBA programs in Access. (Hiroshi Watanabe/Digital Vision/Getty Images)

Access is a relational database management system which provides all the tools to design and automate a database. Visual Basic for Applications or VBA is a computer programming language used to create programs in Access and other MS Office applications. Knowing how to compile a program using Microsoft Office Access can help you expand your programming skills. Write VBA code to create and compile a subroutine in Access in just a few simple steps.

Skill level:


  1. 1

    Start Microsoft Office Access 2007, select "Blank Database" and click "Create." Select "Database Tools" and click "Visual Basic."

  2. 2

    Select the "Insert" menu and click "Module."

  3. 3

    Copy and paste the code below to your new module to create a new subroutine:

    Private Sub accessQueryParameters()

    Dim dB As Database

    Dim rst As Recordset

    Dim strSQL As String

    Set dB = CurrentDb

    strSQL = "CREATE TABLE tmpTable (NumField NUMBER, EmployeeName TEXT, Position TEXT);"

    DoCmd.RunSQL (strSQL)

    strSQL = "INSERT INTO tmpTable (NumField, EmployeeName, Position) "

    strSQL = strSQL & "VALUES (1, 'Ana', 'Teacher');"

    DoCmd.SetWarnings False

    DoCmd.RunSQL (strSQL)

    strSQL = "Select tmpTable.* from tmpTable;"

    Set rst = db.OpenRecordset(strSQL)



    Do While Not rst.EOF

    Debug.Print rst.Fields("EmployeeName").Value & " is a " & _





    End Sub

    The subroutine will create a new table and add records to it. A query will then output the table contents to the output Window. This is an example of how you can create and compile a program using VBA. You can write and compile your own VBA code to perform a desired function.

  4. 4

    Click the "Debug" menu and select "Compile <database name>" to compile the program. Press "F5" to run your subroutine.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.