这是导致错误的代码:
SELECT [serial number], [page count], [minutes], [status], [activity], [venue short name], [assigned to], [publishing format name], [query], [photo], [notes], [tabular], [partpub], [statusdate]
FROM MyProd
WHERE ((MyProd.[Status] = [Forms]![My Prod]![StatusFilter])
OR ([Forms]![My Prod]![StatusFilter] Is Null))
AND ((myprod.[activity] = [Forms]![My Prod]![ActivityFilter])
OR ([Forms]![My Prod]![ActivityFilter] Is Null))
AND ((myprod.[activity] = [Forms]![My Prod]![ActivityFilter])
OR ([Forms]![My Prod]![ActivityFilter] Is Null))
AND ((myprod.[venue short name] Like "*" & [Forms]![my prod]![venuefilter] & "*")
OR ([Forms]![my prod]![venuefilter] Is Null))
AND ((myprod.[assigned to] = [Forms]![My Prod]![ParticipantFilter])
OR ([Forms]![My Prod]![ParticipantFilter] Is Null))
AND ((myprod.[publishing format name] = [Forms]![My Prod]![PubFilter])
OR ([Forms]![My Prod]![PubFilter] Is Null))
AND ((myprod.[query] = [Forms]![My Prod]![PubFilter])
OR ([Forms]![My Prod]![PubFilter] Is Null))
AND (iif([Forms]![My Prod]![SpecialRequestFilter]="Photo", MyProd.[Photo] Like -1, ([Forms]![My Prod]![PubFilter] Is Null)))
AND (iif([Forms]![My Prod]![SpecialRequestFilter]="Query", MyProd.[Query] Like -1, ([Forms]![My Prod]![PubFilter] Is Null)))
AND (iif([Forms]![My Prod]![SpecialRequestFilter]="Table", MyProd.[Tabular] Like -1, ([Forms]![My Prod]![PubFilter] Is Null)))
AND (iif([Forms]![My Prod]![SpecialRequestFilter]="Partial Pub", MyProd.[partpub] Like -1, ([Forms]![My Prod]![PubFilter] Is Null)))
AND (iif([Forms]![My Prod]![SpecialRequestFilter]="Has Notes", MyProd.[Notes] <> "", ([Forms]![My Prod]![PubFilter] Is Null)))
AND (IIf((([Forms]![My Prod]![SD]<>"") AND ([Forms]![My Prod]![ED]<>"")), MyProd.[statusdate] Between [Forms]![My Prod]![SD] AND [Forms]![My Prod]![ED], (MyProd.[StatusDate] Like "*" OR MyProd.[StatusDate] Is Null)))
我看不出这有多复杂...您能建议这个的“简单”版本吗?这些是过滤器,当留空时,结果查询应返回全部。谢谢。