[AccessD] Querydef weirdness

Stuart McLachlan stuart at lexacorp.com.pg
Thu Jul 7 14:44:22 CDT 2005


On 7 Jul 2005 at 15:23, Bobby Heid wrote:

> 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?  

Frequently :-(

> Anyone have a  work-a-round?
> 

I use a static function to hold the value from the control which I set 
immediately before calling the query. Something like 

Static Function TempStore(Optional varInput As Variant) As Variant
    Dim varStore As Variant
    
    'Initialise the variant if the function is called
    'the first time with no Input
    If varStore = Empty Then varStore = Null
    
    'Update the store if the Input is present
    If Not IsMissing(varInput) Then varStore = varInput
    
    'return the stored value
    TempStore = varStore
End Function

Replace [forms]![FormData]![ProjectID] with TempStore() in the query and 
use

"TempStore [ProjectID]" just before you call the query.







-- 
Stuart





More information about the AccessD mailing list