Help with code interpretation

  • Thread starter Thread starter Ayo
  • Start date Start date
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
 
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
 
And intRecordCount will not contain a reliable record count, since it was
not preceeded by
rs.MoveLast
 
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
 

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

Back
Top