Form SQL statement

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

Guest

Hey everyone,
I am working on a purchasing database. I have a form that brings up
the order details (Items, quantities, ect) that is based off the below SQL
statement. My problem is that the CompanyID isn't carrying over to the form
when it opens. Any help you can offer would be really appreciated.

SELECT DISTINCTROW tblPurchase.*, tblCompanies.Name
FROM tblCompanies INNER JOIN tblPurchase ON tblCompanies.CompanyID = _
tblPurchase.CompanyID
Where (((tblPurchase.CompanyID)=[forms]![frmPurchasebySupplier]! _
[CompanyID]));

Troy W.
 
You haven't got the CompanyID in the selection list.

Try:

SELECT DISTINCTROW tblPurchase.*, tblCompanies.CompanyID, tblCompanies.Name
FROM tblCompanies INNER JOIN tblPurchase ON tblCompanies.CompanyID = _
tblPurchase.CompanyID
Where (((tblPurchase.CompanyID)=[forms]![frmPurchasebySupplier]! _
[CompanyID]));
 
Troy, I think you need to explain "CompanyID isn't carrying over to the
form". Also, it's source is 2 separate tables. Which one does not appear?

1) Does it appear in the query?
2) Is it aliased in the query as company ID exists more that 1 time in the
returned recordset?
3) Does it appear in the Field List?


Van T. Dinh said:
You haven't got the CompanyID in the selection list.

Try:

SELECT DISTINCTROW tblPurchase.*, tblCompanies.CompanyID,
tblCompanies.Name
FROM tblCompanies INNER JOIN tblPurchase ON tblCompanies.CompanyID = _
tblPurchase.CompanyID
Where (((tblPurchase.CompanyID)=[forms]![frmPurchasebySupplier]! _
[CompanyID]));

--
HTH
Van T. Dinh
MVP (Access)



Troy W. said:
Hey everyone,
I am working on a purchasing database. I have a form that brings up
the order details (Items, quantities, ect) that is based off the below
SQL
statement. My problem is that the CompanyID isn't carrying over to the form
when it opens. Any help you can offer would be really appreciated.

SELECT DISTINCTROW tblPurchase.*, tblCompanies.Name
FROM tblCompanies INNER JOIN tblPurchase ON tblCompanies.CompanyID = _
tblPurchase.CompanyID
Where (((tblPurchase.CompanyID)=[forms]![frmPurchasebySupplier]! _
[CompanyID]));

Troy W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top