Putting It All Together

When writing your own procedures to create DAO objects, you should include sufficient error handling code, and perhaps even wrap the whole lot in a transaction, and so if any part of it fails, you don't have orphaned objects that you will have to delete manually.

Remember that an orphaned object (one that remains alive in Access's memory space, but not in your application) can easily prevent Access from closing. The other side effect of having orphaned objects is that every object consumes system resources; if you have enough orphaned objects unnecessarily consuming resources, you can quite simply run out, and your application will fail without warning.

You can use the following procedure to manage all the code we've just created, to test the creation of invoice tables, indexes, and relationships:

Public Sub CreateInvoiceSchema() CreateInvoiceTable

CreatePKIndexes "tblInvoice", "InvoiceNo" CreateInvItemTable

CreatePKIndexes "tblInvItem", "InvItemID" CreateRelation "Relation1", "tblInvoice", _

"InvoiceNo", "tblInvItem", "InvoiceNo"

End Sub

0 0

Post a comment