using query in modules

  • Thread starter Thread starter Simon
  • Start date Start date
S

Simon

Hi, I can't figurout anymore how to use querys in a module.
I am using access 97 and I don't understand what I am
doing wrong. here is my code:

Dim fDatabase as databse
dim query as querydef
dim record as recordset

set query = fDatabase.queryDefs("query")
query.Parameters(0) = date1
query.Parameters(1) = date2
set record = query.openrecordset(dbOpenDynaset, dbReadOnly)

when I debug the query it has only 1 record in it but in
access when I double click the query and input the
parameters it has 104 entries.

so I can't work with the query with query.moveNext because
it has always 1 record in it.

I can't figure out what I am doing wrong

thanks a lot

Simon
 
Simon said:
Hi, I can't figurout anymore how to use querys in a module.
I am using access 97 and I don't understand what I am
doing wrong. here is my code:

Dim fDatabase as databse
dim query as querydef
dim record as recordset

set query = fDatabase.queryDefs("query")
query.Parameters(0) = date1
query.Parameters(1) = date2
set record = query.openrecordset(dbOpenDynaset, dbReadOnly)

when I debug the query it has only 1 record in it but in
access when I double click the query and input the
parameters it has 104 entries.

so I can't work with the query with query.moveNext because
it has always 1 record in it.

How do you know it only has one record in the recordset?

If you're checking the recordset's RecordCount property, you
should note that (for non-table type recordsets) it only
reflects the number of records that have been accessed, not
necessarily the total number of records.
 
ok thanks I just found out about what you said and it
works fine, I was just lost in my code and debug infos. I
was freaking out because of recordcount = 1.
thankx

Simon
 
Back
Top