How to Access VBA Programming for Absolute Beginners

Microsoft Access is a database program included in the Microsoft Office suite of applications. With Microsoft Access, create a database to suit your needs using Microsoft's Visual Basic for Applications (VBA) programming language, which is included with every copy of Microsoft Access. VBA is a complex programming language that can perform a variety of tasks and functions. There are a few basic guidelines that are applicable to every VBA macro, or piece of executable code that you write.

Things You'll Need

  • Microsoft Access 2007 or 2010
Show More

Instructions

    • 1

      Start Microsoft Access, then click the "New Blank Database" icon, then click "Create."

    • 2

      Click the "Database Tools" tab on the Ribbon, then click the "Visual Basic" button. This will open the Visual Basic Editor (VBE).

    • 3

      Select "Insert" and then click "Module" to open a blank window.

    • 4

      Type the code into the module window. Every section of VBA code starts with either "Sub" or "Function" and ends with "End Sub or End Function." A subroutine is a piece of code that will return a value, where a function is a piece of code that will not. What code you write depends upon what data is in your database and what you want to do to the data. For example, you could use the following code to calculate a person's age:

      Function age(vb_Dte As Variant)

      Dim v_Age_Calc As Variant

      v_Age_Calc = DateDiff("yyyy", vb_Dte, Now)

      If Date < DateSerial(Year(Now), _

      Month(vB_Date), Day(vb_Dte)) Then v_Age_Calc = v_Age_Calc - 1

      age = CInt(v_Age_Calc)

      End Function

    • 5

      Press "F5" to run the function.

Tips & Warnings

  • Microsoft offers an extensive online help feature to assist you with writing VBA code (see Resources).

Related Searches:

References

Resources

Comments

You May Also Like

  • Access 2007: Tips for Beginners

    Microsoft Access 2007 is a database program. A database gives you a way to structure information into rows (records) and columns (fields)....

  • Introduction to Access Programming

    Programming in Access is the process of adding various functions to your database using either Access macros or Visual Basic for Applications...

  • How to Write an Excel VBA Program

    Microsoft Excel Visual Basic for Applications (VBA) is pretty easy to learn. And with a little practice, you can master this powerful...

  • How to Access VBA Reports

    "VBA reports" refer to the reports in a Microsoft Access database that a Visual Basic for Applications (VBA) program manipulates. One operation...

  • An Absolute Beginner's Guide to Programming

    Programming is writing instructions through a computer language which tells the computing device what to do. Machine code is the lowest form...

  • Absolute Beginner's Guide to Computer Basics

    Whether you're learning how to use a computer for the first time, understanding computer basics is more of a necessity than ever....

  • VBA Access Training

    Access is Microsoft's database application for desktop computers. Visual Basic for Applications, or VBA, is included so that you can write custom...

  • Visual Basic for Applications for Beginners

    Visual Basic for Applications (VBA) is a programming language you can use to customize or extend Microsoft Office applications such as Excel...

  • Microsoft Access VBA Training

    Microsoft Access is a database application that comes bundled with the Microsoft Office suite of applications. Companies use it to create simple...

Related Ads

Featured