By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,247 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,247 IT Pros & Developers. It's quick & easy.

Recordset access and pin-point record question

P: n/a
Hi Guys,

Firstly thanks for all the help you have providing me...

I have another question I was stuck with.

Here is a simple code

dim strsql as string
dim scr as recordset

strsql = "Select A, B, C from somewhere"
scr = docmd.runsql strsql
after I docmd.runsql strsql, i would like to get the result into a
certain record set call "scr". once I have that, I would like to get
the value of B in the Nth record in "scr". Is it possible? Can someone
please give me hints?

Sincerely,

Tom
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Instead of using docmd.runsql you need to open a recordset using your
SQL. Here's some air code using DAO:

dim strsql as string
dim scr as recordset
Dim db As Database, rs As Recordset

strsql = "Select A, B, C from somewhere"
Set db = DBEngine.Workspaces(0).Databases(0)
set rs = db.OpenRecordset(strsql, dbOpenDynaset)

You could use a loop to move through the recordset to get to the Nth
record:

for i = 1 to N
rs.MoveNext
next i

However, there iss usually a better way. You might reconsider your
SQL expression and add a Where clause to get the record of interest.
When your recordset's current record is the record of interest you can
access the value of B using:

rs!B

Hope that helps.

Rick Collard
www.msc-lims.com

On 15 Sep 2003 08:20:09 -0700, ze***@hotmail.com (Tom Lee) wrote:
Hi Guys,

Firstly thanks for all the help you have providing me...

I have another question I was stuck with.

Here is a simple code

dim strsql as string
dim scr as recordset

strsql = "Select A, B, C from somewhere"
scr = docmd.runsql strsql
after I docmd.runsql strsql, i would like to get the result into a
certain record set call "scr". once I have that, I would like to get
the value of B in the Nth record in "scr". Is it possible? Can someone
please give me hints?

Sincerely,

Tom


Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.