[AccessD] Querydef weirdness

Bobby Heid bheid at appdevgrp.com
Thu Jul 7 14:23:48 CDT 2005


Ok, one of my classic stupid Access issues.

I'm using Access XP.  The scenario is I have a form that has a combo box
with projects in it.  I use a union query to add '(All)' to the top of the
list.  When the user selects (All), we want the output to contain all of the
projects.  Otherwise only the project the user has selected.

For this one report, I have this in the where part of the query:

Iif([forms]![FormData]![ProjectID]=0,[project].[projectid],[forms]![FormData
]![ProjectID])

This basically comes out as 'where projectid=projectid' if the
Formdata!ProjectID is 0 
and 'where projectid=[forms]![FormData]![ProjectID]' if the
Formdata!ProjectID is not 0 .

This works fine when running the query by itself or from the report.  Well
the user wanted the sum of the data on the chooser form when a project (or
'(All)' is selected.  So I run the query via a querydef and I get the
infamous 'expected 1 parameters' error message.  If I remove the where part
of the query, it runs fine from the querydef.

I talked to a co-worker and he has had problems accessing forms from a query
in a querydef too.  Has anyone else run into this?  Anyone have a
work-a-round?

Thanks,
Bobby




More information about the AccessD mailing list