Exists predicate required

94Sport5sp

Registered User.
Local time
Today, 06:35
Joined
May 23, 2012
Messages
115
Hi:

I have a form with a command button and some VBA code. After checking that the user has done all that needs to be done then they can click on the command button to print a report. I am having a problem with the report.

The error message I get says I have "Written a subquery that can return more than one field without using the EXISTS reserved word in the Main Query's From clause" and I do not understand the problem so I cannot fix it.

When clicked the button builds a query string which contains "Select * From SalesTbl Where (SalsTbl.Process=True); and then runs a DoCmd.OpenReport, stDocName, acNormal, , strCriteria.
In the above stDocName is the name of an existing report and strCriteria is the above Select statement.

What is Access trying to tell me. Why do I need an EXISTS predicate and where does it go?

Reading in the help and online gives me several examples of using EXISTS to get records from two different tables but I only have one table in play. The report contains fields from the SalesTBL and when I run the above query (as a standalone query) it returns the records I want.

Thanks
 
Hi Paul:

I am not following you on the sample nor why the syntax is incorrect. The Query that I am using is not using any variables from the form. The field "process" is part of the table and was set previously in code to either be true (include for report) of false. All the button is now doing is open the report for those records that are true and print.

Thanks
 
You don't want a complete SELECT statement in the where condition. Try just

"Process = True"
 
Hi Paul:

You are so right. I do not know where my mind was at but I see the problem now. I just wanted the "Where" part of the SQL statement without the Where word.

Works like a charm now.
 

Users who are viewing this thread

Back
Top Bottom