Trying To Compare 2 Tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello I am curretnly working on a Query for a row source lookup on a table
called SrvcAwardTable.

I am trying to return the last name of an Individual whose ID in the
SrvcAwardTable matches theEMPL_ID in the DELTEK_vwCF_AWARDS table.

I have the following SQL statement. Please tell me what i am doing wrong
here.

************************************************************

SELECT DELTEK_vwCF_AWARDS.FIRST_NAME
FROM DELTEK_vwCF_AWARDS, SrvcAwardTable
WHERE (((SrvcAwardTable.ID)=[DELTEK_vwCF_AWARDS].[EMPL_ID]))
ORDER BY DELTEK_vwCF_AWARDS.FIRST_NAME;
************************************************************

Its pretty simple I know but I am stuck.
 
It looks like it should work. What is happening that makes you believe
it isn't working correctly?
 
Whenever I go to the SrvcAwardsTable I get the Value of EMPL_ID as the Field
Value of Last Name ... not the value of Last Name where SrvcAwardsTable.ID
and DELTEK_wvCF_AWARDS.ID match
 
Well, that's weird. Check your table to see if all the rows are like
that. If not, it sounds like a corrupted table. Try the Tools >
Database Utilities > Compact & Repair menu option.
 
Tried it - it does not work ...

MGFoster said:
Well, that's weird. Check your table to see if all the rows are like
that. If not, it sounds like a corrupted table. Try the Tools >
Database Utilities > Compact & Repair menu option.
 
Whenever I go to the SrvcAwardsTable I get the Value of EMPL_ID as the Field
Value of Last Name ... not the value of Last Name where SrvcAwardsTable.ID
and DELTEK_wvCF_AWARDS.ID match

My guess is that you're yet another victim of Microsoft's misdesigned,
misleading, and all but useless Lookup field.

Do you have a Lookup Field for the last name? If so, what is actually
STORED in the table is the ID, not the name. The ID is concealed from
your view by the Lookup Wizard, but that's what's actually there.

John W. Vinson[MVP]
 
Hello I am curretnly working on a Query for a row source lookup on a table
called SrvcAwardTable.

I am trying to return the last name of an Individual whose ID in the
SrvcAwardTable matches theEMPL_ID in the DELTEK_vwCF_AWARDS table.

I have the following SQL statement. Please tell me what i am doing wrong
here.

************************************************************

SELECT DELTEK_vwCF_AWARDS.FIRST_NAME
FROM DELTEK_vwCF_AWARDS, SrvcAwardTable
WHERE (((SrvcAwardTable.ID)=[DELTEK_vwCF_AWARDS].[EMPL_ID]))
ORDER BY DELTEK_vwCF_AWARDS.FIRST_NAME;
************************************************************

Its pretty simple I know but I am stuck.

Since I don't know the structure of your tables, in what way this
isn't working, or the datatypes of the fields, I'm guessing a bit -
but wouldn't a simple Join be better?

SELECT DELTEK_vwCF_AWARDS.LAST_NAME
FROM DELTEK_vwCF_AWARDS INNER JOIN SrvcAwardTable
ON DELTEK_vwCF_AWARDS.EMPL_ID = SrvcAwardTable.ID
ORDER BY DELTEK_vwCF_AWARDS.LAST_NAME;

Your message referred to the last name; your SQL used FIRST_NAME - so
that might be (part of) the problem.

John W. Vinson[MVP]
 
Back
Top