473,387 Members | 1,510 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Recordset access and pin-point record question

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
1 4303
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: j.mandala | last post by:
Someone is trying to run my Access 2002 database under Access 2003. He has had a number of problems: 1) i used the MSComCt2.ocx for it's Date and Time picker. I can't find it under 2003. Do I...
3
by: alex_peri | last post by:
Hello All, I am having problems with sorting a recordset by fields in Access. I have a table with three columns called ID, SNo and Time and would like to sort the records by Time. I would like to...
3
by: BillCo | last post by:
This worked for a large database (150+ tables): Do While Not rstLinks.EOF Set td = DB.TableDefs(rstLinks!Name) 'Debug.Print rstLinks!Name If InStr(td.Connect, "corpbe.mdb") Then td.Connect =...
8
by: Radu | last post by:
Hi, I have the following problem: I open a recordset based on excel/csv files, but then I need to filter (in code) in order to extract only data pertaining to a specific person. This code is...
1
by: bic | last post by:
I use sqlCommand object in conjunction with sqlDataReader but can't find a method that can access a recordset that holds one new id from the SP's select. Thanks. SqlCommand salesCMD = new...
1
by: xcelmind | last post by:
Hello Dev. Guru, I want to at this time introduce myself. I am Stanley Ojadovwa by name. I’m a freelance and a newbie in web application development. I’m currently using ASP as my application...
2
by: curran.george | last post by:
'add one textbox to form1 with Control Source property = ID 'copy/paste the form_load code below: 'Then open the form and then attempt to sort the datasheet 'crashes 2003, error 3450 Access 2007 -...
11
by: Gwindor | last post by:
I have been doing programming in Access for about 10 years. I am now being asked to make an Access front end for data that is stored in SQL Server. My impression is that the only way to do this...
0
by: Octo Siburian | last post by:
I have 2 databases, sql server and ms.access, I want to move existing data in database ms.access to database sql server using looping Dim jlhField As Long Set rsSIKawan = New ADODB.Recordset...
16
by: Magda Balise | last post by:
So as everyone else I am new to PHP and I have been trying to create an amenity page for a B&B. I need folk to be able to select checkboxes and it fetches the info from the database. I posted the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.