Modifying existing code

Modifying existing code isn't all that different from writing new code because you still have to know the exact meaning and syntax of every keyword used in the code. In some cases, the procedure might work as-is in your database. In other cases, you might have to modify the code to get it to work.

If you need to modify the code, you can't do so unless you understand what the code is doing and how it works. Thus, you have to know the purposes of each statement. If you need to modify a statement, you need to know the correct syntax. Like when writing code, you can get more information about existing code by using either of these methods:

^ To see the Quick Info for a line of code, right-click the line and choose Quick Info.

^ For detailed help with a keyword, select (double-click) that keyword and press Help (F1).

Modifying existing code takes almost as much skill and knowledge as writing your own code, so don't expect to be able to get anything accomplished by taking wild guesses. You can see examples of modifying existing code throughout this book. For now, just be aware that you can copy and paste VBA code into a module. Or, if the code is already in some other database's module, you can import that module into your current database.

In Chapter 4, you can pick up more advanced skills for creating procedures. For now, be aware that every VBA keyword has certain rules of syntax, which you must follow to a T if you expect your code to work. You can't expect to learn and memorize every keyword and its syntax in a short time because there are just too darn many keywords. However, after you know how to get help with keywords, you'll always have the information that you need at your fingertips.

0 0

Post a comment