Help with code interpretation

A

Ayo

Hi everyone,
I found this snippet of code in an example I am trying to use for my
application but I am not sure what exactly it does. So I would appreciate any
help in interpreting each line of the code, what it means and what it does.
Thank you

Set db = CurrentDb()
Set qdf = db.QueryDefs("qryMovieSelection")

qdf.SQL = strFullSQL
Set rs = db.OpenRecorset("qryMovieSelection")
intRecordCount = rs.RecordCount
 
S

Steve Schapel

Ayo,

I would assume that there is also somethign else in the code, which you
left out of what you quoted, to give a value to strFullSQL?

So what this code does is:

- looks at an existing saved query (qryMovieSelection)
- changes the query to whatever is defined by strFullSQL
- opens a recordset based on that query, in order to...
- count the records in the query

On face value, I cannot understand the reason for doing it that way, it
seems a bit involuted to me. I think you would get the same result like
this:

Set rs = CurrentDb.OpenRecorset(strFullSQL)
intRecordCount = rs.RecordCount
 
G

George Nicholson

And intRecordCount will not contain a reliable record count, since it was
not preceeded by
rs.MoveLast
 
A

Ayo

Thanks

Steve Schapel said:
Ayo,

I would assume that there is also somethign else in the code, which you
left out of what you quoted, to give a value to strFullSQL?

So what this code does is:

- looks at an existing saved query (qryMovieSelection)
- changes the query to whatever is defined by strFullSQL
- opens a recordset based on that query, in order to...
- count the records in the query

On face value, I cannot understand the reason for doing it that way, it
seems a bit involuted to me. I think you would get the same result like
this:

Set rs = CurrentDb.OpenRecorset(strFullSQL)
intRecordCount = rs.RecordCount
 
Top