kazzi
kazzi

Reputation: 534

If values in one column is entered populate other columns (Access)

So I have an Access database that I'm trying to build and was wondering was there a way that if I type in an ID into one table that it can populate values in the adjacent column from another table.

For example I have table_1 that has columns User ID and User Number.

And now that I'm creating table_2 I want when I enter the User Number that it populates the value for another column which will be User ID, sort of how a vlookup would work in excel.

I already built a relationship for the User Number column in table_2 so when I type in the value its pulling from table_1. But I can't get column User ID to populate with the corresponding value. Thanks

Upvotes: 0

Views: 1557

Answers (1)

ClaireLandis
ClaireLandis

Reputation: 355

You don't need to build a second table that duplicates the data. Since you already have it in table 1 you can always refer to that relationship when querying data and should do so in order to avoid discrepancies between the two tables. In this instance if you want to return the user id from table 1 when you specify a user number you should just create a new query using the sql code:

SELECT table_1.[User Number], table_1.[User ID]
FROM table_1
WHERE table_1.[User Number] IN (12345, 12346, 12347);

In this example, the 12345, 12346, 12347 represent your user numbers for which ID's you were wanting to return; so you should only replace those values with your search parameters.

Upvotes: 1

Related Questions