Using Visual Basic to Automate Your Database 192 After you complete this chapter: · Many of the forms and reports we'll create throughout this book, as part of the HelloWorld example, will include Microsoft Visual Basic code similar to the examples you'll see in this chapter. · To start building forms, queries, and reports as part of a database application, go to Chapter 7, "Designing Basic Forms." If you want to learn more about programming Microsoft Access with Visual Basic, see Chapter 17, "Using Visual Basic to Manage Data." 1. 2. 3. 4. 5. 6. Declare an object variable for a Database object and a TableDef object. Declare a string variable to hold the name of a table and an integer variable to hold the value returned by a message box. Set the Database object variable to the current database. Use the Input function to display an input box that requests the name of a table, assigning the table's name to the string variable. Set the TableDef object variable to the table whose name is entered in the input box. (Use the TableDefs collection to specify the item.) Use the MsgBox function to display a message box asking whether you want to open the table whose name you enter. Use the Name property of the TableDef object, and include Yes and No buttons, an icon of your choosing, and a message box title using the constant you defined earlier. Add an If...Then...Else statement so that if a user clicks Yes in the message box, the proce- dure opens the table in Datasheet view; otherwise, the procedure displays a message box that indicates that no table will be open. Add error-handling code to the procedure that displays a message box, if a user enters a name 7. 8.