Share via

Changing the Datatype From Short Text to Lookup Wizard

Anonymous
2015-09-05T13:54:32+00:00

I need to change a field type, in access 2013, that is short text into a wizard lookup datatype but can't because there is an  error message that states that there are relationships present that won't allow it.  I then deleted the relationships in design view but still the program is stating the same error message.  What should I do to make the change from short text into lookup wizard?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2015-09-05T16:49:33+00:00

    You may well lose data doing this.  Normally the lookup field wizard in essence creates a foreign key column of long integer data type which references an autonumber primary key column of a referenced table.  Consequently existing values in the current short text column will not be compatible with the data type of the column if its data type is changed, so the data will be lost.  To avoid this add a column of long integer data type to the table and update its values to those of the primary key of the referenced table.

    Let's assume as a simple example where you have a text column City in a Contacts table.  Add a long integer CityID column to the table.  Assuming you have a referenced table Cities with an autonumber key CityID and a text column City with distinct value, then execute the following update query:

    UPDATE Contacts INNER JOIN Cities

    ON Contacts.City = Cities.City

    SET ContactsCityID = Cities.CityID;

    Once you are satisfied that the table has been correctly updated you can delete the City column from Contacts and create an enforced relationship between Contacts and Cities on CityID.

    The CityID column in Contacts will of course show its actual numeric values, and I would recommend you leave it as that, but if you really want to see the referenced city names in the table, change its DisplayControl property to a combo box with a RowSource property of:

    SELECT CityID, City FROM Cities ORDER BY City;

    a BoundColumn property of 1, a ColumnCount property of 2 and a ColumnWidths property of 0.

    If the referenced table's key were a 'natural' key, i.e. the City text column in the above example it would be possible to use the lookup field wizard without losing data, but this would not change its data type; it would merely change its DisplayControl property to a combo box.

    2 people found this answer helpful.
    0 comments No comments
  2. Tom van Stiphout 40,201 Reputation points MVP Volunteer Moderator
    2015-09-05T15:32:35+00:00

    You may have missed a few relations.

    Open the relationships window. Delete everything that's on it. Put your table on it, and right-click > Show Direct.

    1 person found this answer helpful.
    0 comments No comments
  3. ScottGem 68,810 Reputation points Volunteer Moderator
    2015-09-05T19:04:32+00:00

    that is short text into a wizard lookup datatype 

    Don't! Evils of Lookup fields

    Lookups should be done on forms using List controls, not on the table level.

    0 comments No comments