Understanding syntax

  • Thread starter Thread starter cinnie
  • Start date Start date
C

cinnie

hello to all

By studying examples in this forum, I'm slowly getting better at
programming. When I see a line like the one shown below, exactly what does
the (0) mean? When I look up OpenRecordset in VBA help, I don't see any
arguments following the first set of brackets.

strRank = CurrentDb.OpenRecordset(strSQL)(0)

thanks
cinnie
 
On Tue, 15 Jan 2008 18:00:00 -0800, cinnie

Don't look at OpenRecordset, but at Recordset Object. That's what
"CurrentDb.OpenRecordset(strSQL)" returns.
Then you can take the 0-est element of that recordset (the first field
in the first record), and assign it to a string value.

More long-winded this could be rewritten as:
dim rs as recordset
set rs = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot)
if rs.recordcount > 0 then
'Recordset pointer is at first record.
strRank = rs.Fields("SomeFieldName").Value

-Tom.
 

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