I'm having a problem when trying to write this query. tblSystemHeaders is a look up table and tblEntry holds the data. I need to select all of the distinct Headings & ExpDet from tblSystemHeaders and then go & grab the detail information from tblEntry. These 2 tables have the field Code as the join. In my report I need to display the Heading and ExpDet along with the detail information from tblEntry. Heres the code so far:
SELECT DISTINCT tblSystemHeaders.ExpDet, tblEntry.CutOff, tblEntry.AcctNum, tblSystemHeaders.lblCheckNo, tblSystemHeaders.lblCreditAmt, tblSystemHeaders.Heading, tblSystemHeaders.lblCreditDate, tblSystemHeaders.lblDebitAmt, tblSystemHeaders.lblDebitDate,tblSystemHeaders.lblAmtDiff, tblSystemHeaders.lblMemo FROM tblSystemHeaders INNER JOIN tblEntry ON tblSystemHeaders.Code = tblEntry.Code WHERE tblEntry.CutOff = '" & Trim(cboCutOff) & "' AND (tblEntry.AcctNum = '" & Trim(txtAcctNum) & "')) ORDER BY tblSystemHeaders.ExpDet
This query gets me the beginning of the result set I'm trying to retreive but when I try to add the additional fields to the query I run into problems. I add in the field tblEntry.CheckNo multiplies the result. I'm just not sure if I'm writing the query wrong or if I have my tables set up wrong. Any help would be appreciated
Thanks,
Corinne
SELECT DISTINCT tblSystemHeaders.ExpDet, tblEntry.CutOff, tblEntry.AcctNum, tblSystemHeaders.lblCheckNo, tblSystemHeaders.lblCreditAmt, tblSystemHeaders.Heading, tblSystemHeaders.lblCreditDate, tblSystemHeaders.lblDebitAmt, tblSystemHeaders.lblDebitDate,tblSystemHeaders.lblAmtDiff, tblSystemHeaders.lblMemo FROM tblSystemHeaders INNER JOIN tblEntry ON tblSystemHeaders.Code = tblEntry.Code WHERE tblEntry.CutOff = '" & Trim(cboCutOff) & "' AND (tblEntry.AcctNum = '" & Trim(txtAcctNum) & "')) ORDER BY tblSystemHeaders.ExpDet
This query gets me the beginning of the result set I'm trying to retreive but when I try to add the additional fields to the query I run into problems. I add in the field tblEntry.CheckNo multiplies the result. I'm just not sure if I'm writing the query wrong or if I have my tables set up wrong. Any help would be appreciated
Thanks,
Corinne