Create drop-down lists from the Advanced Setup
    • Dark
      Light
    • PDF

    Create drop-down lists from the Advanced Setup

    • Dark
      Light
    • PDF

    Article summary

    Create Drop-Down lists from the Designer

    From SQL Spreads 6.0 you can quickly create Drop-Down lists from the SQL Spreads Designer.

    SQL Spreads can create drop-down lists that let the user select a text value from another table but SQL Spreads will insert the key value into the updated table.

    In this demo we have a table with cities which has columns for the city name and the country code. We would like the user to be able to select the full country name in a drop-down list instead of entering the country code. You can download the demo here Drop-down List Demo.

    Drop-down lists must be setup using the Advanced Setup. The easiest way to use the Advanced Setup is to start with selecting a table in the Designer, and then go into the Advanced Setup and do further modifications.

    1. Select the Cities table in the SQL Spreads Designer. This will load the table into Excel, and also create a Database Import and a Database Mapping in the Advanced Setup.

    Cities.png

    1. Go to the Advanced Setup and select Database Mapping option:

    Advanced Setup Database Mapping 7.1

    1. Select the Cities Database Mapping in the list and click Edit.

    Edit.png

    1. Click Yes to accept switching from the Designer to the Advanced Setup:

    Accept switch.png

    1. We would like to add the drop-down list in the CountryCode column. To do so, click the Add button in the right most column for the CountryCode row:

    Add dropdown.png

    1. The dialog for creating the drop-down list is shown. a. First, select the referenced table to fetch the drop-down list values from (Countries). b. Then select which column in the referenced table that contains the key values (the CountryCode). c. Lastly select which column from the referenced table that should be shown in the drop-down list (The country name in the Name column):

    Edit dropdown list.png

    1. Click Ok in all three dialogs to get back to Excel.

    2. We also need to update the import so that the Country name is shown in Excel, instead of the Country Code. We do that by updating the import SQL query that loads data into the spreadsheet. Go to the Advanced Setup and click the Database Import option:

    Advanced Setup Database Import 7.1

    1. Then select the Cities Database Import and click Edit:

    Edit database.png

    1. In the import SQL query we will have to join the Cities table with the Countries table. Then we need to replace the CountryCode column with the country name from the joined Countries table:

    Import query.png

    SELECT 
    
    [Cities].[Id] [Id], 
    
    [Countries].[Name] [Country], 
    
    [Cities].[CityName] [City]
    
    FROM 
    
    [SQLSpreadsDemo].[dbo].[Cities] AS [Cities]
    
    INNER JOIN 
    
    [SQLSpreadsDemo].[dbo].[Countries] AS [Countries] ON [Countries].[CountryCode] = [Cities].[CountryCode]
    
    1. Click Ok three times to go back to Excel.

    2. To update the spreadsheet with the new settings, click the Refresh button. You will now see the drop-down list showing the country name. If you select a new country and click Save, the county code for the selected country will be stored in the Cities table:

    Refresh3.png


    Was this article helpful?