Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT OK, SELECT INTO loses data

Status
Not open for further replies.

FGS

Programmer
Oct 10, 2000
7
DK
When I execute the following in Access 97 (checking whether the customer has a different site address from invoice address):
SELECT ServContrac.ServContrNo AS ContrNo, ServContrac.ICustCodeCon AS ICustNo, ServContrac.CustSiteNo AS Site, IIf(IsNull([CustSiteAdd]![CustomerCode]),[Customers]![CustomerName],[CustSiteAdd]![CustomerName]) AS CustName, IIf(IsNull([CustSiteAdd]![CustomerCode]),[Customers]![Zip-Code],[CustSiteAdd]![Zip^Code]) AS Zip, ZipStart([Zip]) AS Zip4 INTO tbl01temp
FROM (ServContrac LEFT JOIN CustSiteAdd ON (ServContrac.CustSiteNo = CustSiteAdd.[Site^No]) AND (ServContrac.ICustCodeCon = CustSiteAdd.CustomerCode)) LEFT JOIN Customers ON ServContrac.ICustCodeCon = Customers.CustomerCode;
The program leaves NULL in the two calculated fields (does not write the data from the "then" clause)where ever the "if" clause is true. HOWEVER,everything is fine when run as a SELECT query (identical except for INTO statement). This is a little like Newton watching the apple fall UP! Can anyone help?
Thanks in advance
Fred
 
Found my own problem - corrupt data in a primary key field on three records in the site address table. Why this effected the make table query and not the select query is still something I do not understand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top