954,566 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Getting the data from different fields

I have two tables like

Staff Table
............
Staff ID
Staff Name
Age
...and more

Staff Salary Table
..................
Staff ID
Staff Name
basic Salary
...and more

Now I have created the Staff Salary form in which I got the staff ID from the staff table using the lookup wizard query in the Staff ID field of the Staff Salary Table
SELECT [Staff Table].[Staff ID] FROM [Staff Table];

but I need one more

When The staff ID was selected from the drop down list, I need the relevant staff name (from the Staff table) also be displayed in the staff salary from .

Can you please let me know how to do this..

Saharish
Newbie Poster
1 post since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

You need to change the datasource from your form to a join like this:

select [Staff Salary].[Staff ID], [Staff Salary].[Basic Salary], [Staff Table].[Staff Name] from [Staff Salary] Left Join [Staff Table] 
on [Staff Salary].[Staff ID] = [Staff Table].[Staff ID]


PS: You shouldn't have a Staff Name in the Staff Salary table. You can get it with a join like above when you need it and you are saving yourself the trouble of maintenance (updating it's value whenever the value of Staff Name in Staff Table changes).

adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: