select query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have run a select query and now need to write some vb code to run through
the data returned from the query.

Dim rstNew As Recordset

stSQL = "Select * from xxxxxxxx"
Set rstNew = dbsNew.OpenRecordset(stSQL, dbOpenDynaset, dbReadOnly)

If rstNew.RecordCount = 0 Then .....

I don't know what to put in xxxxxxx cause I dont know the name of the
dataset returned from the select query.

thank you,
Neil
 
A couple observations...

"SELECT * from XXXXX" is a select query. Is there any reason you couldn't
just use that in your code, rather than first running a (separate) select
query? That way, you could just name the table. If you SELECT query is
somewhat more complex, so what?! Open the query in design view, change to
SQL view, copy the SQL statement, and paste it into your code.

You are testing the number of records returned BEFORE you tell Access to
count to the end of the recordset. You'll need to use something like:
rstNew.MoveLast
before you try to test the count.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 

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