- Start Database Desktop
- To create a new table, on the main menu, click File -> New ->
Table...
- Create the table as follows:

If you are using Corel Paradox 10, create the table as follows:

- To save the table, click the Save As or the Create button.
- Click the arrow of the Alias combo box and select BCDEMOS
- In the File Name edit box, type MusicAlbums

- Click Save and close the table.
- Reopen the table and enter a few records
|
- If you didn't yet, start Borland C++ Builder or Delphi.
Save the project as MusicCollection
in a new folder created as ExoMusic
- Save the unit as Main
- Design the starting form as follows:

- To use a module, on the Standard toolbar, click the New button
- In the New Items dialog box, click Data Module and click OK
- Change its Name to MusicModule
and save it as DMMusic
- From the BDE tab of the Component Palette, click Table and click on
the module window
- Change its Name to AlbumsTable
- Using the Object Inspector, set the DatabaseName to BCDEMOS
- Set the TableName to MusicAlbums
and set the Active property to true or True
- From the Data Access tab of the Component Palette, click DataSource
and click in the module window
- Change its Name to AlbumsSource

- Using the Object Inspector, set the DataSet to AlbumsTable
- Select the form. On the main menu, click File -> Include Unit Hdr...
- From the Use Unit dialog box, make sure DMMusic is selected and
click OK
- On the form, select all DB* controls and the DBNavigator bar
- Using the Object Inspector, set their DataSource to MusicModule->AlbumsSource
- Set each DB* control (excluding the DBNavigator, of course) to its
corresponding DataField. The DBMemo1 must be set to Notes
- Test the application and return to Bcb or Delphi
|
Creating a Relationship Table
|
|
- Get back to Database Desktop.
To create another table, on the main menu of Paradox, click File
-> New -> Table
- Create the table as follows:

- Save the table as MusicTracks in the BCDEMOS alias.
|
Preparing Grid Lookup Fields
|
|
- Get back to Bcb or Delphi and display the MusicModule window
- Click AlbumsTable and, using the Object Inspector, set its Active
property to false
- From the BDE tab of the Component Palette, click Table
and click in the module window
- Change the Name of the new table to TracksTable
- Set its DatabaseName to BCDEMOS. Set its TableName
to MusicTracks and make sure its Active property is set to
false
- Double-click the TracksTable icon. This opens the Field
Editor
- Right-click in the Fields Editor and click Add All Fields
- To create the field that will be used to select an album,
right-click the Fields Editor again and click New Field
- In the Name edit box, type Album
- In the Type combo box, select String and, in the Size
edit box, type 50
- In the Field Type section, click the Lookup radio button
- Set the Key Field to AlbumID
- Set the Dataset to AlbumsTable
- Set the Lookup Keys to AlbumID
- Set the Result Field to AlbumTitle

- Click OK and close the Fields Editor
- Set the Active property of both tables to true
- From the Data Access tab of the Component Palette, click DataSource
and click in the module window
- Change its Name to TracksSource
and set its DataSet to MusicTracks
|
Lookup Fields on a DBGrid
|
|
- To create a new form, in Bcb or Delphi, on the View toolbar, click
the New Form button
- Change the Name to frmTracks and save its unit as AlbumTracks
- Add a DBGrid to the form and design it as follows:

- On the main menu, click File -> Include Unit Hdr...
- From the list of units, click DMMusic and click OK
- On the form, click the DBGrid and, using the Object Inspector, set
its Data Source to MusicModule->TracksSource
- Right-click the DBGrid and click Columns Editor
- Right-click in the Columns Editor and click Add All Fields
- Click TrackID in the Columns Editor and, using the Object Inspector,
set its Visible property to false
- In the same way, set the AlbumID's Visible property to false
- In the Columns Editor, right-click Notes and click Delete
- In the Columns Editor, drag Album up and position it between
TrackNumber and TrackTitle

- Save everything
- Display the main form and, on the main menu, click File ->
Include Unit Hdr...
- Make sure AlbumTracks is selected and click OK
- Add a button on the right side of the existing controls
- Change its name to btnTracks and its Caption to &Tracks
- Implement its OnClick event as follows:
//---------------------------------------------------------------------------
void __fastcall TForm1::btnTracksClick(TObject *Sender)
{
frmTracks->ShowModal();
}
//---------------------------------------------------------------------------
|
- Test the application:

- Return to Bcb or Delphi
|
Preparing List Lookup Fields
|
|
- Close Bcb or Delphi and open (or return to) Paradox
- Create a new table as follows:

- Save the table as MusicCategories in the BCDEMOS alias
- Enter a few music categories and close the table:

- Reopen the MusicAlbums table (in Paradox) and on the main menu,
click Table -> Restructure...
- Click Label and press Insert
- Add the MusicCategoryID field as follows:

- Save and close the table
|
|
|