Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Folks,

I've got two different data sets.
Number One Contains:
ID(Primary Key), Name, Surname, AreaCode(Foreign Key)
Number Two Contains:
AreaCode(Primary Key), AreaName

Now I want to have all the area's names in my dropdownlist,
but I want to display the area that has been selected for a certain id.

So when I load the app the Area that has been selected say For id 001
to be displayed (and that info is in DataSet 1)
And when i click to see the list i want to see the Area names (and that info is in DataSet 2)
========================================================================

I know about the inner join my SQL Statement looks like this
VB
MainDataTable = Populate("SELECT " _
+ "tblJobReq.Job_ID, tblJobReq.Date, tblArea.Area_Name, " _
+ "tblEmployee.FirstNames + ' ' + tblEmployee.Surname AS Operator, " _
+ "dTblEmp1.FirstNames + ' ' + dTblEmp1.Surname AS 'Requested By', " _
+ "dTblEmp2.FirstNames + ' '+ dTblEmp2.Surname AS 'Attended By' , " _
+ "tblJobReq.Time_Req, tblJobReq.Time_Att, tblJobReq.Time_Comp, " _
+ "tblJobTypes.Type, tblJobReq.Comment " _
+ "FROM tblJobReq " _
+ "INNER JOIN tblArea " _
+ "ON tblJobReq.Area_ID = tblArea.Area_ID " _
+ "INNER JOIN tblJobTypes " _
+ "ON tblJobReq.Job_Type = tblJobTypes.[Job ID] " _
+ "INNER JOIN tblEmployee " _
+ "ON tblJobReq.CRO_ID = tblEmployee.EmployeeID " _
+ "INNER JOIN(SELECT EmployeeID, FirstNames, Surname " _
+ "FROM tblEmployee AS tblEmployee_1) AS dTblEmp1 " _
+ "ON tblJobReq.Req_ID = dTblEmp1.EmployeeID " _
+ "INNER JOIN (SELECT EmployeeID, FirstNames, Surname " _
+ "FROM tblEmployee AS tblEmployee_2) AS dTblEmp2 " _
+ "ON tblJobReq.Att_ID = dTblEmp2.EmployeeID ")


But my application should emulate an ms access form, where you can see what is selected but when you click the dropdownmenu to change it the it only displays the option in the area table for example.

when I use this datatable the dropdown menu contains duplicates, and that I don't want
Posted
Updated 20-Jan-10 19:53pm
v2

What you need to do is use an inner join to write a SQL statement that contains the data from both tables, linked via the AreaCode. I can't write it without knowing the table names, but it would be a good exercise in the most basic of SQL techniques for you to do some research and come up with it yourself anyhow. SQL INNER JOIN is what you need to google, if you have no book.
 
Share this answer
 
If I'm understanding your problem correctly, I'd load the dropdown control with an SQL statement like this:

SELECT DISTINCT AreaCode, AreaName FROM tblArea


Set the dropdown's value to AreaCode and display to AreaName. Then based on the data in your MainDataTable (a different SQL statement) select the currently saved option in the dropdown.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900