Hello,
I am trying to open a report from a form with a where condition that will match ProjectID to ProjectID AND ActionItemType (field name on the report) = "Risk". Opening to the projectID works fine. I am trying to add the condition for [ActionItemType]="Risk" and I receive and error "Can't find the field '1' referred to in your expression" when I try the following:
DoCmd.OpenReport "rptProjectActionItems", acViewReport, "", "[ProjectID]=" & ProjectID And "Risk=" & [ActionItemType], acNormal
I have been unable to find an example with two where conditions to obtain the correct syntax.
Any help would be appreciated.
Thank you very much.
-Scott
Where condition in OpenReport argument
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
-
- Administrator
- Posts: 78558
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Where condition in OpenReport argument
The word And should be within the quotes:
Or is ActionType the field name and should its value be the word "Risk"? If so:
Code: Select all
DoCmd.OpenReport "rptProjectActionItems", acViewReport, , "ProjectID=" & Me.ProjectID & " And Risk=" & Me.ActionItemType
Code: Select all
DoCmd.OpenReport "rptProjectActionItems", acViewReport, , "ProjectID=" & Me.ProjectID & " And ActionType='Risk'"
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 402
- Joined: 14 Apr 2010, 15:59
Re: Where condition in OpenReport argument
DoCmd.OpenReport "rptProjectActionItems", acViewReport, , "ProjectID=" & Me.ProjectID & " And ActionType='Risk'" did what I was hoping.
Once again thank you for your help.
Once again thank you for your help.