This sample chapter is excerpted from Sams Teach Yourself Microsoft Access 2002 Programming in 24 Hours.
All programs use data. Access is a kind of program that uses two types of data: permanent and temporary. Permanent data can be stored in a database; this type of data is remembered even when Access is not running in memory. Temporary data, on the other hand, is used by your program in memory but is not kept in memory when your Access program is not running.
Permanent memory involves the use of magnetic media, such as a floppy or hard disk drive, a CD-ROM drive, or a tape drive. Temporary memory is the memory used in integrated semiconductor computer chips, called Random Access Memory, or RAM.
In this hour, you will learn how to store data temporarily in RAM. The temporary RAM memory is where data manipulation occurs. You might store some kinds of data permanently, but no usable data will exist on your hard disks or tapes unless it is used in RAM memory.
Your computer and the Windows operating system handle much of the hard part of using RAM. You must, however, take some specific steps to use data in your programs, and you'll learn about these steps in this hour.
In this hour, you will learn
How to use the essential data-declaration statements
How to use and evaluate data with code
How to use Access pop-up hints
How to try code in the Immediate window
How to use the Watches window
How to use the call stack
How Memory Is Used
Permanent memory and temporary memory are both important to Access programmers. Database files are stored on your hard drive when your Access programs aren't running, and they are copied to RAM when you need to use them in your programs.
Hard disk drives use magnetism to encode data. RAM uses microswitches. Fortunately for us, the computer handles magnetizing hard drives and electrifying semiconductor switches. The computer also handles the accessing of disk drives and semiconductor memory. The operating system gets the data from RAM and disk drives. The workhorse behind these operations is the microprocessor. If you have an Intel Pentium 800, for example, that big semiconductor controls the movement of data in and out of RAM.
The electrical wire along which information travels is referred to as a bus. The microprocessor's address and data bus store the information of where data resides in memory. The piece of the puzzle I haven't yet discussed is the bridge between the memory address of data and how you refer to it.
A microprocessor needs some specific instructions and an address to use computer data internally. The missing piece includes the code you write and the VBA compiler. When you write code, you use the Visual Basic for Applications (VBA) language. Access has a compiler that converts what you write into addresses the computer can use.
A compiler is a program that converts text written in a programming language to machine-readable code that the computer can use.
A compiler is the necessary bridge between the text you write in a programming language and memory, which is what the computer needs to carry out your instructions. Memory is where your program does its work. When you declare a variable in your Access program, the compiler assigns an address to that variable.