Re: Problem with Embeded Queries



Try using the Domain Aggregate functions instead of the embedded query.

DSum()
DMax()

I believe the examples in the help file only show one limiter in the "where"
part of the function, but it will accept And/Or statements to chain together
more than one limiter. Also, the field name in the first part can be an
equation but it still has to be enclosed in quotes. The Domain Aggregate
function will run the equation.

--
Wayne Morgan
MS Access MVP


"John Ortt" <JohnOrtt@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:42e8e276_1@xxxxxxxxxxxxxxxxxxxxxxxxx
> Hi there,
>
> I am trying to do a two level embeded query but it is causing Dr Watson
> errors.
>
> The line which is causing the problem is:
>
> CFCDeci: (Select sum (FlexChangeDeci) FROM [qryFlexi] as [qryFlexi2] WHERE
> ([qryFlexi2].[DateID] <= [qryFlexi].[DateID]) and ([qryFlexi2].[DateID] >=
> [qryFlexi].[PrevFlex]);)
>
> specifically ([qryFlexi2].[DateID] >= [qryFlexi].[PrevFlex]) as it works
> when I remove this.
>
> Prev Flexi was defined in an earlier query with another embeded query,
> could
> this be what is causing the problem?
> The code for PrevFlex is below:
>
> PrevFlex: (Select max (dateID) FROM [tblflexi] as Temp WHERE
> [temp].[dateid]
> <= [qrytimes].[dateid])
>
> Any help would be gratefully appreciated.
>
> Thanks,
>
> John.
>
> P.S. The rest of the SQL can be posted if it is of help.....
>
>


.



Relevant Pages

  • Re: an easy one
    ... Is this not an access newsgroup? ... The help file would have told you runquery is not a legal action. ... I'm rusty and actually have never ran a query from code. ... There is an Access help and a VBA help. ...
    (comp.databases.ms-access)
  • Re: Show only certain records in a query by date and time
    ... I had thought about those 2 at one time but for some reason ... answers using Jeff Conrad's favorite sites, and the help file in access ... I have a query with a dtt field that has therapy end dates, ... expiration date in the field and also records that have expiration dates ...
    (microsoft.public.access.gettingstarted)
  • RE: Automatically Delete Duplicated Data in Table
    ... The second half of the help file went OK also and a new ... table was created minus all the duplicates. ... Create a new query based on the Original table containing duplicates. ... > click Append Query. ...
    (microsoft.public.access.queries)
  • Re: Last record search not working
    ... I guess I didn't see the note in the help file. ... "Douglas J. Steele" wrote: ... records are usually returned in no particular order (unless the query ... Doug Steele, Microsoft Access MVP ...
    (microsoft.public.access.queries)
  • Re: Question on Queries
    ... The help file mentions this, but it only mentions Make Table and Append ... I haven't tried it with a Select query. ... WITH OWNERACCESS OPTION Declaration ... If you want to enforce workgroup security settings and users' permissions, ...
    (comp.databases.ms-access)