recordset for sum query

  • Thread starter Thread starter Alex
  • Start date Start date
A

Alex

I have a Query1 with the following fields:
ProductID, Sum([qty]* [usage]) As StandardUsage, Day
where Day >=#SomeDate1# And Day<=#SomeDate2#
and
Query2 - Sum(Query1.[StandardUsage]) As StandardKg giving
as a result a one number.
The queries are working Ok.
But, when I'm doing
Set rst = dbs.OpenRecordset("SELECT StandardKg FROM
Query2").
I'm getting an error "Too few parameters. Required two."
It happens even if I'm doing just
Set rst = dbs.OpenRecordset("Query2")

Could anybody help with it?

Thanks
 
You have two parameters that Access resolves, but JET
can't do, SomeDate1 and SomeDate2.

I would do something like:
(Air Code here)

Dim dteStart as Date
Dim dteEnd as Date
dim strSQL as String
dteStart = Inputbox("Enter Start Date")
dteEnd = InputBox ("Enter End Date")


StrSQL = "Select Sum (StandardUsage) as StandardKG From
(Select ProductID,Sum([qty]*[usage]) as StandardUsage,Day
where Day between #" & dteStart & "# AND #" & dteEnd & "#)
as Query1"

dim dbs as dao.database
dim rst as dao.recordset

set dbs=currentdb
set rst =dbs.openrecordset(strsql)


Chris Nebinger
 
Thanks a lot, Chris.
-----Original Message-----
You have two parameters that Access resolves, but JET
can't do, SomeDate1 and SomeDate2.

I would do something like:
(Air Code here)

Dim dteStart as Date
Dim dteEnd as Date
dim strSQL as String
dteStart = Inputbox("Enter Start Date")
dteEnd = InputBox ("Enter End Date")


StrSQL = "Select Sum (StandardUsage) as StandardKG From
(Select ProductID,Sum([qty]*[usage]) as StandardUsage,Day
where Day between #" & dteStart & "# AND #" & dteEnd & "#)
as Query1"

dim dbs as dao.database
dim rst as dao.recordset

set dbs=currentdb
set rst =dbs.openrecordset(strsql)


Chris Nebinger


-----Original Message-----
I have a Query1 with the following fields:
ProductID, Sum([qty]* [usage]) As StandardUsage, Day
where Day >=#SomeDate1# And Day<=#SomeDate2#
and
Query2 - Sum(Query1.[StandardUsage]) As StandardKg giving
as a result a one number.
The queries are working Ok.
But, when I'm doing
Set rst = dbs.OpenRecordset("SELECT StandardKg FROM
Query2").
I'm getting an error "Too few parameters. Required two."
It happens even if I'm doing just
Set rst = dbs.OpenRecordset("Query2")

Could anybody help with it?

Thanks



.
.
 
Back
Top