using query in modules

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
 
M

Marshall Barton

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.
 
S

simon

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top