• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 14. Building N-Tier Applications > Building the Middle-Tier Component

Building the Middle-Tier Component

To move an application to the n-tier model, you must remove all data access code from the user interface and place it in a DLL. Here are the steps involved:

1.
Launch Visual Basic.

2.
Indicate that you want to create an ActiveX DLL (see Figure 14.2) and click Open. The Visual Basic environment appears as in Figure 14.3.

Figure 14.2. Launch Visual Basic and create an ActiveX DLL project.


Figure 14.3. The Visual Basic environment after creating an ActiveX DLL project.


3.
Return to the Access VBE and right-click the Customer class.

4.
Select Export File. The Export File dialog box appears (see Figure 14.4).

Figure 14.4. The Export File dialog box allows you to export an Access module or class module to a text file.


5.
Enter Customer.cls as the name of the file you are exporting and click Save. Access exports the class to a text file.

6.
Perform the same steps to export the basVariables module to basVariables.bas.

7.
Return to Visual Basic.

8.
Select the project in the Project Explorer and click Properties. The Properties window appears (see Figure 14.5).

Figure 14.5. Use the Properties window to change project properties.


9.
Click the Name property and rename the project to Customers. The project should appear as in Figure 14.6.

Figure 14.6. Change the name of the project to Customers.


10.
Right-click Class1 and select Remove Class1 (see Figure 14.7). Click No when asked if you want to save the file.

Figure 14.7. Right-click to remove Class1 from the project.


11.
Right-click the project and select Add, Class Module (see Figure 14.8). The Add Class Module dialog box appears.

Figure 14.8. Right-click the project and select Add, Class Module to add a new class module to the project.


12.
Click the Existing tab and locate the class module that you exported in step 5 (see Figure 14.9).

Figure 14.9. Click the Existing tab and locate the class module that you exported in step 5.


TIP

An alternative to steps 11 and 12 is to use the Ctrl+D keystroke combination. Ctrl+D invokes the Add File dialog box, allowing you to easily add a new object to the project.

13.
Click Open. The Customer class module should now appear as part of the project (see Figure 14.10).

Figure 14.10. After adding the class module, it appears as part of the project.


14.
Right-click the project and select Add, Module. The Add Module dialog box appears.

15.
Click the Existing tab and locate the standard module (basVariables) that you exported in step 6. Click Open. Visual Basic adds the basVariables module to the project.

16.
Select the Customer class and change the Instancing property of the class to MultiUse (see Figure 14.11).

Figure 14.11. Change the Instancing property of the class to MultiUse.


17.
Unlike Access, Visual Basic does not automatically create a reference to the ADO object library. Use Project, References to add a reference to the Microsoft ActiveX Data Objects type library.

18.
Select File, Make Customers.dll. The Make Project dialog box appears.

19.
Click OK to make the DLL. This process creates the DLL and registers it on your machine.

20.
Close Visual Basic and save the project and any modules if prompted.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint