L
LMB
Hi Guys,
I have a database a programmer created years ago in Access 2.0. It is now
converted to Access 2000 and I want to join a few tables together to get a
report. When I try to concantenate the physician name, I get the following
error when trying to run the query. I know it's because LastName and
FirstName are also fields in the client table but I don't know how to get
the my Name field to use the physician table to pull the info from. I use
the design grid when creating my queries. I did select the Physician Table
to get the info from but I must need to fix the SQL, I went to the website
below but don't really understand the language enough to know just how to
fix it. I was thinking on the way home from work...Do I need to make a
query with just the physicians and physician link in it and concantenate the
name in there and then join that to this query?.....Thanks, Linda!
Error: The specified field 'LastName' could refer to more than one table
listed in the From clause of your SQL statement.
http://www.sjsoft.com/docs/jworkbook/sqlreference.htm#from
SELECT DISTINCTROW Clients.[Inactive?], Schedule.Date, Schedule.Description,
Schedule.Letter, Clients.LastName, Clients.FirstName, Clients.Contact,
Clients.HomePhone, [Client-Physician Link].PhysicianID, Physicians.LastName,
Physicians.FirstName, Physicians.[FirstName] & [LastName] AS Expr1
FROM Physicians INNER JOIN ((Clients INNER JOIN [Client-Physician Link] ON
Clients.ClientID = [Client-Physician Link].ClientID) INNER JOIN Schedule ON
Clients.ClientID = Schedule.ClientID) ON Physicians.PhysicianID =
[Client-Physician Link].PhysicianID
GROUP BY Clients.[Inactive?], Schedule.Date, Schedule.Description,
Schedule.Letter, Clients.LastName, Clients.FirstName, Clients.Contact,
Clients.HomePhone, [Client-Physician Link].PhysicianID, Physicians.LastName,
Physicians.FirstName, Physicians.[PhysiciFirstName] & [LastName]
HAVING (((Clients.[Inactive?])=No) AND ((Schedule.Date) Between
DateValue([Beginning Date]) And DateValue([Ending Date])) AND
((Schedule.Description)="needs final visit scheduled" Or
(Schedule.Description)="needs phone f/u" Or (Schedule.Description)="needs
scheduled" Or (Schedule.Description)="next appt." Or
(Schedule.Description)="Make inactive if no phone call" Or
(Schedule.Description)="needs 1st Phone Follow Up" Or
(Schedule.Description)="Needs Final Phone Follow Up" Or
(Schedule.Description)="Need Plan Back"))
ORDER BY Clients.[Inactive?] DESC , Schedule.Date, Clients.LastName,
Clients.FirstName;
I have a database a programmer created years ago in Access 2.0. It is now
converted to Access 2000 and I want to join a few tables together to get a
report. When I try to concantenate the physician name, I get the following
error when trying to run the query. I know it's because LastName and
FirstName are also fields in the client table but I don't know how to get
the my Name field to use the physician table to pull the info from. I use
the design grid when creating my queries. I did select the Physician Table
to get the info from but I must need to fix the SQL, I went to the website
below but don't really understand the language enough to know just how to
fix it. I was thinking on the way home from work...Do I need to make a
query with just the physicians and physician link in it and concantenate the
name in there and then join that to this query?.....Thanks, Linda!
Error: The specified field 'LastName' could refer to more than one table
listed in the From clause of your SQL statement.
http://www.sjsoft.com/docs/jworkbook/sqlreference.htm#from
SELECT DISTINCTROW Clients.[Inactive?], Schedule.Date, Schedule.Description,
Schedule.Letter, Clients.LastName, Clients.FirstName, Clients.Contact,
Clients.HomePhone, [Client-Physician Link].PhysicianID, Physicians.LastName,
Physicians.FirstName, Physicians.[FirstName] & [LastName] AS Expr1
FROM Physicians INNER JOIN ((Clients INNER JOIN [Client-Physician Link] ON
Clients.ClientID = [Client-Physician Link].ClientID) INNER JOIN Schedule ON
Clients.ClientID = Schedule.ClientID) ON Physicians.PhysicianID =
[Client-Physician Link].PhysicianID
GROUP BY Clients.[Inactive?], Schedule.Date, Schedule.Description,
Schedule.Letter, Clients.LastName, Clients.FirstName, Clients.Contact,
Clients.HomePhone, [Client-Physician Link].PhysicianID, Physicians.LastName,
Physicians.FirstName, Physicians.[PhysiciFirstName] & [LastName]
HAVING (((Clients.[Inactive?])=No) AND ((Schedule.Date) Between
DateValue([Beginning Date]) And DateValue([Ending Date])) AND
((Schedule.Description)="needs final visit scheduled" Or
(Schedule.Description)="needs phone f/u" Or (Schedule.Description)="needs
scheduled" Or (Schedule.Description)="next appt." Or
(Schedule.Description)="Make inactive if no phone call" Or
(Schedule.Description)="needs 1st Phone Follow Up" Or
(Schedule.Description)="Needs Final Phone Follow Up" Or
(Schedule.Description)="Need Plan Back"))
ORDER BY Clients.[Inactive?] DESC , Schedule.Date, Clients.LastName,
Clients.FirstName;