Getting Help on Code

 < Day Day Up > 

Few of us ever get so good at writing code that we stop making mistakes. In fact, most of us spend a lot of time perfecting (fixing) code. Fortunately, the VBE provides a powerful and flexible Help system that's completely separate from the Access 2003 Help system.

Open the Visual Basic Help task pane shown in Figure 2.11 to access all this information. There are two ways to do so. Choose Help, Microsoft Visual Basic Help or choose View, Toolbars, Task Pane.

Figure 2.11. Search for help on VBA topics in the new Visual Basic Search task pane.

graphics/02fig11.jpg


This task pane works similar to the old Help system but doesn't usurp your entire VBE container window. Enter a word or phrase in the Search control to return a list of links in the Search Results task pane.

TIP

The quickest way to get help is to position the cursor in the middle of a keyword (function, property, method) and then press F1. The Help system displays the most appropriate topic on the selected term.


Helpful Shortcuts for Entering Code

You can rely on the VBA Help topics for quick information about the VBA language, but sometimes, you don't need quite so much information. As you enter code into a module, a special feature called IntelliSense kicks in. When the VBE can guess what you might be about to type, it displays a pop-up window with appropriate values to help you complete the statement.

The list is always context-sensitive. You may have noticed this happening when you were entering the first bit of example code. To illustrate this feature, let's work through another example.

  1. On a fresh line in the Immediate Window, type DoCmd. (including the period character). As soon as you enter the period character, the VBE displays the pop-up shown in Figure 2.12.

    Figure 2.12. The pop-up list limits its contents to values that are relevant to the word you're entering.

    graphics/02fig12.jpg


  2. Choose OpenForm from the list. You can use the scroll bar to find it, or you can press the Down arrow until it's visible. Highlight OpenForm and then press Tab (or double-click).

  3. Enter a space character and the VBE displays a new list. This time the list contains the OpenForm's arguments as shown in Figure 2.13.

    Figure 2.13. This feature can display a method's arguments.

    graphics/02fig13.jpg


  4. The first argument is the form's name. After entering an appropriate reference and the following comma, the VBE displays the next argument constants, as shown in Figure 2.14. You haven't been introduced to arguments or constants yet. In this case, they both represent values used by the OpenForm method. You'll learn more about arguments and constants throughout this book.

    Figure 2.14. Choose from a limited list of constants.

    graphics/02fig14.jpg


If you need help but the list isn't visible, right-click the keyword to display the list shown in Figure 2.15. Click the appropriate option for additional help. (This action in the Immediate window is less useful because the resulting list is much shorter.)

Figure 2.15. Right-click a keyword to get additional help.

graphics/02fig15.jpg


     < Day Day Up > 


    Automating Microsoft Access with VBA
    Automating Microsoft Access with VBA
    ISBN: 0789732440
    EAN: 2147483647
    Year: 2003
    Pages: 186

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net