user2037559
user2037559

Reputation: 135

Access 2016 - Display foreign key value instead of id

Here is a screenshot of my lookup wizard (sorry, I couldn't change the language from german). But I don't want to display an ID in "Ort". I want to dispay two values the table has instead.

To generalize this question: "How can I show the values of a foreign key in a lookup instead of the id?"

Cheers

Upvotes: 0

Views: 2841

Answers (2)

sgtGiggsy
sgtGiggsy

Reputation: 115

I know it's a bit late, but hopefully, I can help someone else, who has the same problem. The best solution, in my opinion, is to join two tables in the RowSource property, and select values from there. Let's assume that you have the Ort and Typ attribute in the same table as GName. Let's call this table: tableofgname. Let's assume you try to read the value of Ort attribute from a table name tableofort. In this case you should enter something like this in RowSource: SELECT [tableofgname].[GName], [tableofgname].[Typ], [tableofort].[Ort] FROM tableofgname INNER JOIN tableofort ON [tableofgname].[Ort] = [tableofort].[OrtID] That way you'll see the value of Ort instead of its ID number.

Upvotes: 0

June7
June7

Reputation: 21370

I expect you want to retrieve and save the Ort value as foreign key, otherwise don't bother to include in query. Set up combobox properties like:

RowSource: SELECT Ort, GName, Typ FROM yourtablename;
BoundColumn: 1
ColumnCount: 3
ColumnWidths: 0";1";2"
ControlSource: the field to save Ort in

I NEVER build lookups in table, only comboboxes or listboxes on form.

Upvotes: 1

Related Questions