How to Refresh a VBA Query in Access

How to Refresh a VBA Query in Access thumbnail
In a few steps, you can write VBA code to refresh a query in Access.

Knowing how to refresh a Microsoft Access query in Visual Basic for Applications (VBA) is important when you have controls displaying information through a query. An Access query is written in structured query language (SQL). You can write SQL queries in VBA to access information in relational databases such as the ones in Access. As you update information in a table, you also want to refresh the information displayed in your control. In just a few steps, you can write a sub to refresh a query in VBA.

Instructions

    • 1

      Start Microsoft Access 2007 and click the "Create" tab. Click on "Table," type "Smith" and press "Enter" to add a new record. Save the table as "Table1." Click "Create" and select "Form Design" to create a new form.

    • 2

      Add a new "List Box" control from the "Controls" menu. Add a new "Button" control to the form.

    • 3

      Right-click anywhere on the form and select "Properties." Select "Form" on "Selection type" and select the "Event" tab. Select "[Event Procedure]," next to "On Load," and click the ellipsis to open Microsoft Visual Basic.

    • 4

      Type the following to define a query for your list box control:

      Me.List0.RowSource = "SELECT Table1.Field1 FROM Table1;."

    • 5

      Switch windows to Microsoft Access and right-click the button control. Select "Properties" and click the "Event" tab. Select "[Event Procedure]," next to "On Click," and click the ellipsis.

    • 6

      Type the following to refresh the query:

      Me.List0.Requery.

    • 7

      Switch Windows to Microsoft Access and click on "View" to run the form. You will see "Smith." Open "Table1" and type "Jones" on the second row to enter a new record. Save and close "Table1." Click the "Command" button on your form to refresh the query in your list box control.

Related Searches:

References

  • Photo Credit black binary numbers image by .shock from Fotolia.com

Comments

You May Also Like

  • How to Access Query Refresh

    Not displaying the latest information in your database application can be a problem if the data displayed is used to make critical...

  • Access: VBA Execute Query

    Microsoft Access is a part of the Microsoft Office suite. Using this software, you can create individual databases, reports and forms. Access...

  • How to Run a Query in Access VBA

    Microsoft Access, part of the Microsoft Office suite, is a program for creating and managing data. Visual Basic for Applications (VBA) is...

  • How to Save a VBA Query on Access

    Knowing how to save a query using Visual Basic for Applications in Microsoft Access can save you time when creating multiple queries....

  • How to Query HTML Tables With VBA Access

    Visual Basic for Applications (VBA) is the programming language for Microsoft's database program Access. VBA can perform the same functions available in...

  • How to Refresh a Pivot Table in Excel

    Microsoft Office Excel is a spreadsheet and data analysis software that allows users to organize data. Data is arranged in grids of...

  • How to Print a Query in Access and VBA

    One of the biggest benefits of Microsoft Access is its Windows-based interface that allows users to design queries without an extensive knowledge...

  • How to Refresh Data in Access

    The Microsoft Access database software stores information in a table and displays it using queries and reports. As new information is entered...

  • How to Do an Access 2007 Update Query

    Access 2007 is a database program created by the Microsoft Corporation. It is an important part of the Microsoft office suite because...

  • How to Access a 2007 VBA Run Query

    Microsoft Access 2007 is the Windows database program with the graphical query interface. Running queries against Access 2007 databases gives users the...

  • Access: How to Refresh Form Data

    When working in a large team, you may occasionally find yourself using a shared database. Other users could be changing the same...

  • How to Refresh Subform Data in Access

    The addition of forms to an Access database serves to make the database more accessible to users who are unfamiliar with the...

  • How to Access VBA Query Results

    Knowing how to read the results from a Microsoft Access query can help you make your Access application more dynamic. Access is...

  • How to Access VBA Query SQL

    Visual Basic for Applications (VBA) is a computer programming language engineered by Microsoft and used to automate routine tasks in Access. Access...

  • How to Access a VBA Delete Query

    Knowing how to delete data from a table in Microsoft Office Access using a delete query can save you time if you...

  • Access: VBA Export Query

    Knowing how to export query results to a text file allows you to make your database application more dynamic and user-friendly. Microsoft...

  • How to Use VBA in Access Query Design View

    Visual Basic for Applications (VBA) is a programming language used in standalone applications, and also to extend the functionality of Microsoft Office...

  • How to Create a Query in Access VBA

    Knowing how to quickly create a query in Microsoft Access and then use it with Visual Basic for Applications (VBA) can save...

Related Ads

Featured