Forum Discussion

RJF61's avatar
RJF61
Copper Contributor
Mar 01, 2023

Form and Subform

I have a main Form named frmProjQry.  Within this main form, I have 5 subforms.  One subform is named sfrmWO (based on tblWO) while a second is named sfrmALbr (based on tblALbr).  I want sfrmALbr to display records where tblWO.WONo = tblALbr.WOOrder AND tblALbr.Cost Element <> to 890001 or 890002.

 

The following SQL for sfrmALbr is pulling records where tblWO.WONo = tblALbr.WOOrder; however, it continues to also include records where tblALbr.Cost Element is = to 890001 or 890002.

 

SELECT tblALbr.[Cost Element], tblALbr.[Cost Element Name], tblALbr.[Posting Date], tblALbr.TotalQty, tblALbr.[Valin RepCurLbr]
FROM tblWO LEFT JOIN tblALbr ON tblWO.WONo = tblALbr.WOOrder
WHERE (((tblALbr.[Cost Element])<>890001 Or (tblALbr.[Cost Element])<>890002) AND (([tblWO].[WOOrder])=[Forms]![frmProjQry]![sfrmWO]![WONo]))
ORDER BY tblALbr.[Posting Date];

 

Is there an error with my syntax or logic?

  • arnel_gp's avatar
    arnel_gp
    Steel Contributor

    run your query to find out if it has error.

    you may also use this as your Criteria:

    ...
    ...
    WHERE (NOT ((tblALbr.[Cost Element]) IN (890001, 890002))) AND (([tblWO].[WOOrder])=[Forms]![frmProjQry]![sfrmWO].Form![WONo]))

Share