Question SIMPLE question on JOINS, getting "NAME" from "ID"

section.echo

New member
Joined
Dec 1, 2013
Messages
3
Programming Experience
Beginner
I really am trying to figure this out but just cannot get it right. I have 2 tables, "tblSalesMain" and "tblRepMain".
I am trying to return to a combobox a reps first and last name instead of an "ID". For example, when a sale is selected it will show all of the info of the sale in different controls, there will be three comboboxes with the reps that sold the item, I can get it to display the "ID" of the reps but not return the NAMES of the reps. I am an amatuer trying to learn a few things honestly, this is what I have been trying although I KNOW it is not nearly correct..

Select SaleID, RepID1, RepID2, RepID3
FROM tblSalesMain as s
INNER JOIN tblRepMain
ON s.RepID1 = tblRepMain.RepID

The tblRepMain table has "tblRepMain.RepFName" and "tblRepMain.RepLName", how can I return to a combobox the reps First and last name instead of the "ID" which currently returns for me.. ANY help will be GREATLY appreciated! Remember, I am a beginner..lol
 

Herman

Well-known member
Joined
Oct 18, 2011
Messages
882
Location
Montreal, QC, CA
Programming Experience
10+
Well actually it IS nearly correct:

SELECT s.SaleID, r.RepFName. r.RepLName
FROM tblSalesMain s
INNER JOIN tblRepMain r ON s.RepID1 = r.RepID
                        OR s.RepID2 = r.RepID
                        OR s.RepID3 = r.RepID
 

section.echo

New member
Joined
Dec 1, 2013
Messages
3
Programming Experience
Beginner
THANK YOU!! Another question....

Well actually it IS nearly correct:

SELECT s.SaleID, r.RepFName. r.RepLName
FROM tblSalesMain s
INNER JOIN tblRepMain r ON s.RepID1 = r.RepID
                        OR s.RepID2 = r.RepID
                        OR s.RepID3 = r.RepID


But how do I get the "RepFName" & "RepLName" into the combobox instead of returning the RepID?
 

section.echo

New member
Joined
Dec 1, 2013
Messages
3
Programming Experience
Beginner
Actually to get the result i am getting i was using the data bindings in the properties of the combobox..i have a lot to learn. And i can only get the first name to appear in the combobox, i know somewhere i need to use & to get both the repfname and replname in the box. Basically i designed a form that i ultimatley am going to use, but for nowi just have a test form i am using to get used to displaying data.
 
Top Bottom