Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6153867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:09:52+00:00 2026-05-23T20:09:52+00:00

I am using this SQL query SELECT TOP 11 StockPrices.Close FROM StockPrices WHERE StockPrices.Date

  • 0

I am using this SQL query

SELECT TOP 11 StockPrices.Close FROM StockPrices WHERE StockPrices.Date >=#2009-03-23# AND StockPrices.ID=1 ORDER by StockPrices.Date;

in VBA to fetch and store the data and keeping in a recordset

SQLQuery = "SELECT TOP 11 StockPrices.Close FROM StockPrices WHERE StockPrices.Date >=#" & tempDate & "# AND StockPrices.ID=" & tempId & " ORDER by StockPrices.Date;"
Set rst2 = db.OpenRecordset(SQLQuery)
Pd = rst2.Fields(0)
Pd1 = rst2.Fields(1)
Pd5 = rst2.Fields(5)
Pd11 = rst2.Fields(10)
rst2.Close

While Pd is being queried perfectly, but I am not able to access the rest of the data. As I understand, there is only one Field here, i.e the Close, which is coming up as Fields(0), I want to access the other data in the same field..

Let me give you an example, the queried result of the above SQL query is like this

3940
2544
5544
5633
1257
9855
3267
3141
2731
6931

SO I want the first, the second, the fifth and the tenth data in the listm which should be stored in Pd, Pd1,Pd5 and Pd11.

Any help, in how to do this?

Soham

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T20:09:54+00:00Added an answer on May 23, 2026 at 8:09 pm

    With Pd1 = rst2.Fields(1) you are accessing the second column of the current row.
    If you want to access the second row, you need to use rst2.MoveNext.
    Below code would save all results to the results() array.
    You could access the fifth result with results(4).

    Dim i as Integer
    Dim results(11) as Integer
    i = 0
    Do while Not rst2.EOF
        results(i) = rs2.fields(0)
        i = i + 1
        rst2.MoveNext
    Loop
    

    To move a number of steps you can use rst2.Move 4 i.e. for moving four steps.
    The best way would be to only get the rows you need (1,5 and 11).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using this SQL query: Select * from table_name what happens if the name
I have a query something like this: SELECT title, desc, date FROM tablename ORDER
I'm using SQL Server 2005. The query would look like this Select col1, col2,
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
We want to be able to select top N rows using a SQL Query.
I'm using this SQL query to create an index: $query = CREATE INDEX id_index2
I would like to turn this query to regular inline sql without using stored
Let's say I have the following simple query SELECT TOP 1 name FROM months
Here's the query: SELECT top 100 a.LocationId, b.SearchQuery, b.SearchRank FROM dbo.Locations a INNER JOIN
How can I do this query with NHibernate select top 10 count(distinct classedition.createdby_id) as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.