473,786 Members | 2,571 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4315
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.Worksp aces(0).Databas es(0)
set rs = db.OpenRecordse t(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.c om (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
7865
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 need to send it to them? 2) I have a function to fill a table with values, that store the page and column numbers of a display of staff members. I had him check the link to Microsoft DAO 3.6 Object Library under references, but it still won't...
3
35468
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 sort them in the actual database and not just Order them with SQL. I have included the code I wrote below. Please bear in mind that I am very new to Access and SQL. I used the Helpfile of Access for this code but i can't make it work for me....
3
1948
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 = ";DATABASE=" & strDestDatabase & ";TABLE=" & rstLinks!Name td.RefreshLink End If
8
2349
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 slow.... I am thinking that there might be another way to do it... maybe faster. Is there a way to filter it as I open it ? I'm using the following simple code:
1
941
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 SqlCommand("sp_GetEdgilTransactionId ", nwindConn); salesCMD.CommandType = CommandType.StoredProcedure;// StoredProcedure; nwindConn.Open(); SqlDataReader myReader = salesCMD.ExecuteReader();
1
3073
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 server technology with Microsoft access as my database source. Just as I have introduced myself, I’m a newbie in web application development. I’m currently working on an application that will allow
2
3526
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 - I can't find much info on this... - Can someone explain what's happening and how to fix this? Private Sub Form_Load() '2008-01-11 Dim rsx As ADODB.Recordset Set rsx = New ADODB.Recordset rsx.CursorLocation = adUseClient
11
5100
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 is to use a .adp application, rather than an .mdb file. Is that correct? Is it possible to use DAO or ADO with .adp objects? Also, is there a good manual on making access front ends for SQL
0
1072
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 Set rsDataRAS = New ADODB.Recordset Set rsSQL = New ADODB.Recordset QuerySelect = "SELECT a.DN, b.DIN, c.PIN, " & _
16
4115
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 checkbox list to the ampage and now I need to search the database for the matching records. so I know I need to write foreach ($_POST as $value) { $breakfast = what $bbq $kitchenette } can someone check to see if I wrote...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.