Expected end of statement

The Expected end of statement message is another common (and rarely helpful) compile error. Once again, all the message is telling you is that you have some sort of syntactical error in the statement. In Figure 12-6, the string literal MyForm at the end of the statement is highlighted, but that only tells you that the compiler got lost at that point. Expected end of statement compile error. The real problem with the statement in Figure 12-6 is the comma between DoCmd and OpenForm. The correct...

Controlling Access through VBA

Working with objects and collections Understanding properties and methods Using properties and methods in VBA code Help with objects, properties, and methods sing Visual Basic for Applications (VBA) in Access is all about writing code to manipulate Access objects, which is just about everything you see on your screen in Access. Coming up with a simple example is difficult because virtually everything is an object. Every table, query, form, report, page, macro, and module is an object. Every...

Copying the label report

To play it safe with original objects, SkipLabels works with copies of those objects. This next statement uses the CopyObject method of the DoCmd object to make a copy of the label report. Notice how it uses ReportName, passed to the procedure in an argument, to determine which report to copy. DoCmd.CopyObject, LabelsTempReport, acReport, ReportName Referring to the earlier examples of calling SkipLabels with the syntax Call SkipLabels (My8462Labels,7), after the preceding line executes, the...

Setting References to Object Libraries

To manipulate the objects in an object model through VBA, you need to set a reference to the appropriate object library. That part is easy because you just have to put a check mark next to the appropriate object library's name in the References dialog box. To open the References dialog box and choose your object libraries, follow these steps (in the Visual Basic editor program window) 1. Choose ToolsOReferences from the Visual Basic editor menu bar. The References dialog box, as shown in Figure...

Customizing Lists and Drop Down Menus

Programming combo boxes and list boxes Linking lists Updating one form's control from another form Cool combo box tricks 7yping information into forms takes time, and typing always means the possibility of typographical errors. Any time you can eliminate typing by giving the user something to click, you're making your data entry quicker and more accurate. Combo boxes and list boxes are both good tools for giving the user options to choose from when typing would otherwise be necessary. A combo...

Working with Class Procedures

Every form in a database has a class module in which you can store code that's used only by that form. To get to a form's class module, you first have to click Forms in the database window and then open an existing form in Design view or create a new form. Typically, you want to tie your code to an object and event. For example, a button on a form is an object. Every button has an On Click event that occurs whenever a user clicks the button in Form view. If you want to write code that runs...

Seeing whether a form is open

VBA can requery a control only on a form that's open. If a form is closed, there's no way to (and no reason to) requery any of its controls because any list controls on the form will be created (and hence up-to-date) the moment when the form opens. If VBA code tries to requery a control on a form that's closed, the procedure crashes, and an error message appears onscreen. Not good. To get around the problem of the Form_AfterInsert() procedure crashing when the Orders form isn't open, put the...

Adding controls to the dialog box

The form properties that you change to control the appearance and behavior of a form don't affect how you add controls to the form. You can still use all the standard techniques that you'd use in Access to create a form for scrolling through records. For example, to add a bound control to the form, click a control type in the Toolbox. Then drag the underlying field's name from the Field List to the form. To add an unbound control to the form, click a control type in the Toolbox and then click...

Thou Shalt Not Covet Thy Neighbors Knowledge

Nobody was ever born already knowing how to use a computer, already knowing how to do database management, or as a fresh out-of-the-womb VBA programmer. Everyone who already knows this stuff went through the same learning curve you're faced with. Thou shalt not consider one's self stupid for not knowing things from birth, for such is the plight of all humankind. Thou shalt earn and learn thy skills like everyone else by learning, doing, and knowing how to get the information you need when you...

Reaching Out with VBA

ven though the focus of this book is on using VBA to program Microsoft Access, that doesn't mean that VBA works only in Access. VBA is actually a programming language for all the programs in Microsoft Office, including Microsoft Word, Excel, and Outlook. In this part, you'll discover some tools and techniques for using VBA to automate transferring data among those programs and even programs that aren't part of Microsoft Office at all.

Responding to a runtime error

When your code generates a runtime error and you're given the choices shown in Figure 12-11, you have three or four choices 1 Continue If code execution was suspended when the error occurred, clicking the Continue button will resume execution at the next line of code in the procedure. This option is disabled (not available) in most cases. i End Clicking this button terminates code execution and takes you back to the Code window without going into step mode. i Debug Clicking this button stops...

Help with arguments

Refer to Figure 3-5 (of the Help page for the MsgBox keyword) to see the Settings section (below the argument descriptions) that provides some specific info on using the buttons argument. You can use either the constant or the value in the command. For example, if you want the MsgBox statement to show both an OK and a Cancel button (rather than just an OK button), you would use either the value 1 or the constant vbOKCancel as the second argument in the MsgBox statement. Arguments are always...

Print a Report

If you want VBA to print a report from the current database, use the syntax DoCmd.OpenReport reportName, acViewNormal where reportName is the name of any report in the current database. For example, the following statement prints a report named MyLabels DoCmd.OpenReport MyLabels, acViewNormal A question in the screen with Yes No buttons. In case you hadn't noticed, the DoCmd (pronounced do command) object shows up quite a few times in this chapter. That's because the DoCmd object lets you do...

Opening and Closing Forms

VBA doesn't limit you to working with individual controls on forms. You can work with entire forms as objects, too. For example, VBA can open a closed form and display it onscreen. The OpenForm method of the DoCmd (do command) object gives you great flexibility in exactly how VBA opens a form. The syntax for using the OpenForm method of the DoCmd object is DoCmd.OpenForm formName, View , FilterName , WhereCondition , DataMode , WindowMode OpenArgs Only the first argument, formName, is required....

Finding standard modules

A standard module contains VBA code that's accessible to every table, query, form, report, page, and macro within the current database. Like those other objects, standard modules get their own button in the Object list at the left side of the database window (refer to Figure 1-1). When you click the Modules button, the main pane shows the names of standard modules (if any) within the current database, as in the example shown in Figure 1-3. Don't be surprised if you click the Modules button in a...

Trapping runtime errors

As you can see in the preceding example, when a runtime error occurs, you get two pieces of information in the message box that appears (see Figure 12-12). Note the error number (referred to as Err.Number or the Number property of the Err object in programmer lingo). That number is of no value to a human user but can be handy for a programmer. The other piece of information that the error message provides is the error description, referred to as Err.Description in VBA. The error description is...

Closing a form

To close a form that's already open, use the Close method of the DoCmd object and the following syntax DoCmd.Close objectType, objectName, SaveOptions i objectType Describes the type of object being closed. Use acForm for forms (acReport for reports). i objectName The name of the form (or other object) to close. i SaveOptions Specifies how to handle the record currently displayed by the form using one of the following constants acSaveYes (the current record is saved automatically) acSaveNo (the...

Listing Skeletal Structure of Code to Distinguish between Left and Right Mouse Clicks

Private Sub ObjectName_MouseDown(Button As Integer, _ Shift As Integer, X As Single, _ Y As Single) 'Code for left mouse button. If Button acLeftButton Then 'Code to execute for left button goes here. MsgBox You pressed the Left mouse button End If 'Code for right mouse button. If Button acRightButton Then 'Code to execute for left button goes here. MsgBox You pressed the Right mouse button End If 'Code for middle mouse button. If Button acMiddleButton Then 'Code to execute for middle button...

Making Decisions in VBA Code

Decision-making is a big part of programming because most programs need to be smart enough to figure out what to do, depending on the circumstances. Often, you want your code to do one thing if such-and-such is true but do something else if such-and-such is false. You use conditional expressions to determine whether something is true or false. A conditional expression is one that generally follows this syntax where Value is some chunk of information, and the ComparisonOperator is compares the...

The Role of Functions in VBA

All the functions that are available to you in Access are also available to you in VBA. In VBA, you use the same function syntax that you use in Access. In Access, the Expression Builder is a good tool for finding out what functions are available as well as how to use them. If you're in an Access Design view and don't see a Build button to click, you can click the Build button in the toolbar to open the Expression Builder. After you're in the Expression Builder, click the + sign next to...

Programming Access Forms

Using VBA with Access forms Enabling and disabling form controls Changing colors, fonts, and special effects Opening and closing forms from VBA ne of the most common uses of VBA is to make your Access forms better and easier to use. As a database developer, you always want your forms to make data entry as quick and error-free as possible. Although there's plenty that you can do in Access along those lines without using VBA, you can often make things just a bit better by writing a little VBA...

Understanding VBA

Visual Basic is a programming language a language for writing instructions that a computer can read and process. VBA is a programming language that's specifically designed to work with the application programs in Microsoft Office including Word, Excel, Outlook, and of course, Access. When you write text in a programming language (as opposed to writing in plan English), you're writing code. Programmers use the term code to refer to anything that's written in a computer programming language. For...

Writing your own error handlers

When writing your own code and your own error handlers, it's not realistic to assume that you can anticipate every possible environmental condition that might cause the procedure to crash. For starters, you can just write the basic code to trap the error, display the error number and description in a simple message box, and then exit the procedure gracefully. Assume that you've already written a procedure, and now you want to add some error-handling to that procedure. Exactly what the procedure...

Table of Contents

About This Conventions Used in This What You're Not to Foolish How This Book Is Part I Introducing VBA Part II VBA Tools and Part III VBA, Recordsets, and Part IV Applying VBA in the Real Part V Reaching Out with Part VI The Part of Icons Used in This Web Site for This Where to Go from Part 1 Introducing VBA Chapter 1 Where VBA Fits In Taking a Look at Understanding Seeing Where VBA Finding standard Finding class From VBA to Finding Out How VBA Discovering VBA Recognizing VBA Chapter 2 Your VBA...

Running code when the user makes a choice

To make a procedure execute after the user chooses an option from a combo or list box, tie the procedure to the control's After Update event. For example, when the user chooses to different field to search on from the Search Field option on the Fancy SkipLabels form (the FldToSearch control), the Look For Value drop-down menu needs to be updated to show unique values from that field. To make sure that the ValueToList control gets updated whenever the user chooses a different field to search, I...

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,...

Identifying the icons for objects properties and methods

The Object Browser, as well as the menus that appear in the Code and Immediate windows, uses icons to help you visually discriminate between objects, properties, methods, and other items in the object model. Table 5-1 briefly describes the meaning of each icon. Refer to the Object Browser in Figure 5-5 (left side) to see some of the icons in action. Table 5-1 Icons Used in the Object Browser and the Code Window Table 5-1 Icons Used in the Object Browser and the Code Window

Thou Shalt Not Bear False Witness against Thy Object Browser

Everything in an Access database is an object. VBA exists to manipulate those objects programmatically. Thy Object Browser is thy Word and Shepard. It leadeth you to code that actually works. It helpeth to remind you that Forms and Reports refer to open objects and that AllForms and AllReports work with closed objects. For example, the Object Browser helpeth you to discriminate between the DoCmd object and the DoCmd property. It taketh you to the land of truth and facts, and bestoweth upon you...

Understanding Compilation and Runtime

How a machine (like your computer) works and how your brain works are two entirely different things. All machines are basically dumb as rocks because they're just machines. Your computer is nothing more than a mindless machine that can pump a few billion instructions per second through a little toenail-sized wafer. No thought nor thinking nor awareness is involved in any of that. It's all just electrons zooming around at the speed of light in a controlled manner inside a small area. Each of...

Linking to External Data through Code

The TransferDatabase method of the VBA DoCmd object also provides a syntax for linking to an external table (but not a query). Note that the first argument after TransferDatabase is acLink rather than acImport. Other than that, the syntax is basically the same DoCmd.TransferDatabase acLink, Microsoft Access, pathToExternalDB, acTable, _ externalTbl, localTableName For example, the DoCmd.TransferDatabase (as shown here) sets up a link from the current database to an external table named CCSecure...

Skipping Over Used Mailing Labels

Suppose that you often use Access to print mailing labels on individual sheets. Each time you print a partial sheet of labels, you end up with some extra unused labels on the sheet. If you reuse that sheet of labels in the printer, Access will print right on the missing labels. Basically, you can't reuse a sheet of labels that's already partially used. That's not good because labels aren't cheap. A solution to the problem is to pop up a dialog box like the one shown in Figure 8-5 just before...

Importing ExportingLinking to Anything

As you might know, you export data from Access to a variety of formats. You can do so interactively (without code). Here's how. 1. In the database window, click the table, query, or other object that you want to export. 2. Choose FileOExport from the Access menu bar. 3. In the Export dialog box that appears, choose a document type from the Save As Type drop-down list. 4. Navigate to a folder, enter a filename for the exported data, and click the Export button. If you want to automate the...

Interacting with Microsoft Excel

Vba Multiplication Table Programming

Microsoft Excel is a great program for playing what-if scenarios with data because it lets you plug data and formulas into cells in whatever manner you wish. Excel isn't good, however, at managing large volumes of data. For large volumes of data, you need a database like Microsoft Access. Microsoft Access can certainly do any math calculations that Excel can do. Playing what-if scenarios with data in Access is not so easy, though, because you need to get queries and or forms involved. It's just...

What the Heck is SQL

Although you might not realize it, every time you create a query in Access, you're actually creating an SQL statement. This is a good thing because as a rule, creating a query in Access is a lot easier than writing an SQL statement from scratch. To illustrate how every query is really a SQL statement in disguise, Figure 7-1 shows a basic Access Select query that in Datasheet view displays some fields and records from a table. So where's the SQL statement in Figure 7-1 Well, it's not visible...

Listing Code to Fill a Combo Box Value List Property

'Create a string variable named NewValList Dim NewValList As String NewValList Chr 34 First Item Chr 34 NewValList NewValList Chr 34 Second Item Chr 34 NewValList NewValList Chr 34 Third Item Chr 34 NewValList NewValList Chr 34 Fourth Item Chr 34 'At this point, NewValList contains 'First Item Second Item Third Item Fourth Item 'Make new string the Row Source for value list named OpsCombo Me OpsCombo.RowSourceType Value List Me OpsCombo.RowSource NewValList 'Set selection to first item in...

General VBA Editor Shortcut Keys

The shortcut keys in Table 17-2 are available throughout the VBA editor and are therefore also available in the Code window and Immediate window. The shortcut keys in Table 17-2 are available throughout the VBA editor and are therefore also available in the Code window and Immediate window.

Getting keyword help

Whether you're typing your own code or trying to modify someone else's, you can get information on any keyword at any time. Just select doubleclick the keyword right in the Code window where it's typed. Then press the Help key F1 on your keyboard. The Help window that opens describes the command and its syntax. After you type a keyword into a procedure, it's very easy to get more detailed help. Just select double-click the keyword, right where you typed it, and press the Help key F1 . This is...

Seiect queries Versus action queries

Sample Action Query

So far in this chapter, I've really only talked about Access select queries. That type of query gets its name from the fact that it only selects fields and records from a table. A select query will never alter the contents of a table. An action query is different from a select query in that an action query actually does change the contents of a table. In Access, you create action queries in much the same way you create select queries. You start off by creating a new, regular query, so you're at...

Designing a message box

You can use the buttons argument of the MsgBox keyword to define the exact appearance and behavior of your message box. Each possible value for the buttons argument can be expressed as either a constant or a number. You can add the constants or numbers together to combine properties. For example, the constant vbYesNo or number 4 tells MsgBox to display Yes and No buttons in the form. The constant vbQuestion or number 32 tells MsgBox to display a question mark icon in the form. Combining the two...

Listing field names

Classmodule Vba

If you want a list box or combo box to list the names of fields in a table or query, set the control's Row Source Type property to Field List and set its Row Source property to the name of the table or query that contains the fields whose names you want to list. For example, Figure 10-3 shows a ComboBox control named FldNameCombo on a form. As you can see in the Properties sheet, its Row Source Type is set to Field List, and its Row Source is set to Customers. The names in the control's...

Using the Num Word function

For the sake of example, assume that you already put NumWord into a standard module in your database. You already have a table that contains data to be printed on checks. Just to give this whole example some context, suppose you have a table with field names and data types similar to those shown in the sample Payables table in Figure 11-6. The left side of the figure shows the table's structure, and the right side of the figure shows some sample data in the table. Sample field names and data...

Square brackets represent names

The rules for referring to field names in VBA are the same rules used in Access expressions. When referring to a field name that contains blank spaces, you must enclose the field name in square brackets, like this Sales Tax Rate . If the field name contains no blank spaces, the square brackets are optional. For example, the name SalesTaxRates in VBA refers to a field named SalesTaxRates, even without the square brackets. Many programmers put square brackets around all field names for a couple...

Proper Case Function

Take a look now at a somewhat larger custom function that does more than a simple match calculation. Suppose you have a table filled with names and addresses, but for whatever reason, all the text is in uppercase or lowercase . For example, maybe the table has a Name field containing names like JOE SMITH or joe Smith. You want to tidy that up, but you certainly don't want to go in and retype all the data manually. Technically, you could just use the built-in StrConv string,3 function to solve...

Changing special effects

Text boxes and some other controls on forms have a Special Effect property that define their general appearance on the form. When you're creating a form in forms Design, you set a control's Special Effect property in the Properties sheet. If you want your code to change a control's special effect, use the syntax where controlName is the name of the control whose effect you want to change, and setting is either the number or constant as shown in Table 6-2. Table 6-2 Using a Constant or Number as...

Get to Know the DoCmd Object

The DoCmd object is one of your most potent programming allies because it can do virtually anything you can do in Access's program window. When you type DoCmd. into the Code window, the hefty list of items that appears in the little menu see Figure 16-3 represents various methods of the DoCmd object. Each method, in turn, represents something that the DoCmd object can do. The DoCmd methods that you're most likely to use, especially as a beginning programmer, are summarized in Table 16-1. Like...

Importing from External Databases

You can import data from any external Access table or query into a table in the current database. There are a couple of advantages to this approach. When you import, you actually create a table, within the current database, that contains an exact clone of the external table or query. Secondly, the imported data are stored in a normal, local Access table. After the table exists in the current database, all other objects in the database that depend on that table work just fine. No special...

Hidden values in combo and list boxes

A combo box or list box can show any data from a table or query even though the control contains some simple value like an Integer. The integer, which is usually a primary key value, can be hidden in the control as the control's actual value while some more meaningful to humans text is shown to the user. This disappearing value act works thanks to multicolumn lists and the Bound Column property. Here, in a nutshell, is how it works 1 Whatever is in the first column of the list is what shows...

Storing SQL statements in variables

You can store SQL statements in variables, just as you can store text in variables. This can help with those extremely long SQL statements that seem to extend out forever past the right margin of the Code window. Many programmers will use this technique of building a long SQL statement out of smaller chunks, storing the statement in a variable. As an example, here is a series of VBA statements that build and execute a single length SQL statement from smaller chunks 'Create string variable...

Using For Each loops

The specific number assigned to each item in a collection isn't terribly important. What is important is the fact that VBA provides some special commands for looping through a collection also called enumerating a collection , where the code looks at each object in a collection either to get information about it or to change it. The special code is a slight variation on the For Next loop called a For Each Next loop. The basic syntax for the For Each Next loop is For Each objectType in...

More DoCmd methods for forms

The DoCmd object used in the preceding example to open and close forms provides many methods for working with data on forms. Table 6-3 summarizes some of the more commonly used DoCmd methods for working with forms and data in forms. Table 6-3 Commonly Used DoCmd Methods You don't need to study and memorize them all now because you can easily get detailed information on an as-needed basis. Just type the beginning of the statement into your code, as follows Just double-click the method name such...

Setting form properties

Creating a dialog box in Access is similar to creating any other form. You don't even need any VBA code to create the box. Rather, you just create a form and set its Form Properties so that the form looks and acts like a dialog box. Here's how 1. In the database window, click the Forms button and then click the New button. 2. In the New Form dialog box that opens, choose Design View. If you created a table for storing settings, choose the table's name from the Choose the Table or Query Where...

Giving users a quick f ind

You can use a combo box as a tool for allowing a user to quickly find a specific record in a table. For example, suppose you have a form that allows a user to find and edit customers. At the top of that form, you could provide a drop-down menu, perhaps named Quick Find or something, as in Figure 10-17. When the user chooses a name from the drop-down menu, the form instantly displays that customer's record. I also point out some of the properties for the QuickFind control in that figure. You can...

Using the continuation character

When writing VBA code, you can break a long line into two lines by using a continuation character, which is just an underscore _ . Many programmers use continuation characters to break lengthy VBA statements into two or more lines. This is especially true with code you see printed in books and such because the code needs to fit within the margins of the book. For example, here's a fairly long line of code that barely fits within the margins in this book Public Sub MySum anyName As String,...

Ask the User a Question

If you want your VBA code to ask the user a question and then perform some action based on the user's answer, you need to use the more complex MsgBox function syntax and an If Else End If block of code with the general syntax as shown here variableName If variableName vbYes Then 'Code to execute if user clicked Yes goes here. Else 'Code to execute if user clicked No goes here. End If I variableName is a name of your own choosing such as Answer . I prompt is the text of the question that the box...

Avoiding Multiple Tables and Links

One of the big tricks to using the TransferDatabase method is being aware of how it names the table or link that it creates. It won't overwrite an existing table. If the current database already contains a table or link with the name that you specify in the localTableName argument, Access creates a new table or link with a number added to the name. For example, if CCSecureTable already exists when you run the code to import its data, Access creates the new table as CCSecurel. Run the code...

Using the PCase function

Like with any custom function, you can use PCase wherever you would use a built-in function. Look at an example where you have a large table of names and addresses, where everything is in uppercase, as in Figure 11-3. For the sake of example, call this table UglyCustomers which isn't an insult to the customers just the way their names are typed in . Now that you have a PCase function that can convert text to proper case without messing up the Mc's, Mac's and P.O.'s you can use that in an update...

Using VBA to position the cursor

With VBA, you can move the cursor to any control on a form. In programmer jargon, moving the cursor to a control is called giving that control the focus. When you type, your text appears in whatever control on a form currently has the focus. VBA itself doesn't actually use square brackets. In fact, about the only time you see square brackets in VBA is when you're looking at a syntax chart, where square brackets are used to identify optional as opposed to required arguments. Access, however,...

Changing and Deleting Table Records

Vba List Records

Any Access update query or delete query will also convert nicely to VBA. For example, suppose you keep track of which new customers you've sent e-mail to by using a Yes No field named SentWelcome in a table. Customers who have been sent the message have True in that field customers who haven't been sent the message have False in that field. For the sake of example, say that this table also has a field named Email that's either the Text or Hyperlink data type that contains each customer's e-mail...

Accessing the Object Library

In order for VBA to manipulate a program or a document within a program VBA first needs to have access to that program's object library. You might envision VBA as sort of a steering wheel that can control any program to which it has access through an object library , as in Figure 14-1. VBA can control any program through that program's object library. To write code for an Office application program, you first need to set a reference to that program's object library. To do so, starting from...

Listing Table Query field Values

The third type of combo box list box that you can create gets its values from a field or fields in a table or query. The Row Source Type for such a list is Table Query, and the Row Source is generally a SQL statement that specifies which fields and values to show in the list. Back up a moment and take a look at the bigger picture. Suppose you want to create a drop-down list that shows an alphabetized list of all unique Company names from a table. By unique, I mean that if a given company name...

Working with Select Queries and Recordsets

So far in this chapter, I've focused mainly on Access action queries that you execute from VBA by using DoCmd.RunSQL. Select queries, which only display data and never change the contents of a table , are a completely different story. In Access, you don't run a select query. You simply switch from Query Design view to Datasheet view to see the records returned by that query. And in VBA, you don't use DoCmd.RunSQL to execute a select query. Rather, you store the results of the query in a weird,...

Responding to a Msg Box button click

If your dialog box asks a question, you presumably want your VBA code to respond to whatever button the user clicked. That's fairly easy to do because when the user clicks a button, the variable to the left side of the MsgBox function returns a value indicating which button the user clicked. Each button that you can show in a message box returns a unique value. For example, when the user clicks the Yes button, MsgBox returns 6 which also equals Access's built-in vbYes constant . If the user...

Fitting the recordset with data

With the VBA statements that define a connection and name for the recordset out of the way, you can finally write the code that actually adds data to the table. That's where the .Open method comes into play. In all the earlier examples, I used a relatively simple statement to fill the recordset. The full syntax for creating an ADO recordset looks like this myRecordSet.Open SQLStatement .Connection ,CursorType ,LockType All the arguments after SQL statements are optional, so that's why you...

Sending Email via Outlook

Access Vba Mail

Suppose you want to be able to send e-mail messages to people listed in a table named Customers in an Access database. You are absolutely certain that you can send and receive e-mail with Microsoft Outlook. Important None of the code described here will work with Outlook Express or a Web browser. For this example, say you want to create a standard form letter-type e-mail message to whatever customer a user chooses from a drop-down menu, as in Figure 14-4. There, the controls named MsgAddress...

Copyandpaste code from the

Many programmers start their careers not so much by writing code from scratch but rather by using code that others have written and adapting it to their own needs. When that code is displayed onscreen, as in a Web page, the first step is to copy and paste the code into a module, where you select what you want to copy, copy it press Ctrl C , click in your module, and paste press Ctrl V . Suppose you're browsing the Web, and you come across a sample procedure in a Web page. You don't want to...

Programming Combo and List Boxes

When working with combo and list boxes through VBA, you'll often want to start with just a simple unbound control one that's not attached to any field in the form's underlying table or query and then let VBA control the properties. To add an unbound ComboBox or a ListBox control to a form, first make sure that the form is open in Design view and that the Toolbox see Figure 10-2 is open. To prevent the Control Wizards from helping you create the control, click the wizard's button until it's no...

Function to Print Check Amounts

Suppose you want to use Access to print checks from a table of payable amounts. You have your printer, and you have your preprinted checks, and maybe you've already created a report format to print the checks. But what about the part of the check where you're supposed to write out the dollar amount, such as One Hundred Thirty Five and 49 100 How are you going to get that part of the check printed There's no built-in function capable of doing that for you. And heaven knows you don't want to type...