473,405 Members | 2,310 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,405 software developers and data experts.

problem with initalise the query results to an array

sir,
in my database i have a query which is taking the subjectcodes for a particular testid.
suppose if for particular testid it takes ma,phy,che , i want to insert the query results in array in my code.
can we pass the query values to an array.
dim subcode as variant is there in my code.
how to do this
please help me....
thanks in advance.
Apr 5 '07 #1
3 1943
Rabbit
12,516 Expert Mod 8TB
You'll have to either use a DLookup if there's some sort of ID to go by or you'll need to open up the query as a recordset and step through to assign the values to the array.
Apr 5 '07 #2
ADezii
8,834 Expert 8TB
sir,
in my database i have a query which is taking the subjectcodes for a particular testid.
suppose if for particular testid it takes ma,phy,che , i want to insert the query results in array in my code.
can we pass the query values to an array.
dim subcode as variant is there in my code.
how to do this
please help me....
thanks in advance.
Here is a Code Snippet that will point you in the right direction. The following assumptions are made:

__1. Table Name: tblTest
__2. Field to Query on: [testid]
__3. Field values to place into Array: [subjectcodes]
Expand|Select|Wrap|Line Numbers
  1. Dim MyDB As DAO.Database, MyRS As DAO.Recordset, MySQL As String
  2. Dim intNoOfRecords As Integer, intConter As Integer, astrCodes() As String
  3.  
  4. MySQL = "SELECT * FROM tblTest WHERE tblTest.testid=3"
  5.  
  6. Set MyDB = CurrentDb()
  7. Set MyRS = MyDB.OpenRecordset(MySQL, dbOpenSnapshot)
  8. MyRS.MoveLast: MyRS.MoveFirst
  9.  
  10. intNoOfRecords = MyRS.RecordCount
  11.  
  12. ReDim astrCodes(1 To intNoOfRecords) As String
  13.  
  14. For intCounter = 1 To intNoOfRecords
  15.   astrCodes(intCounter) = MyRS![subjectcodes]
  16.   MyRS.MoveNext
  17. Next
  18.  
  19. MyRS.Close
Apr 5 '07 #3
Denburt
1,356 Expert 1GB
Check out the getRows method in the VBA help file.
Just slightly more efficient.
Apr 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: point | last post by:
Hy guys... I need some help... In an object i have $this->data as array of mysql query results(see example) and a function in_multi_array() which isn't important.It just seraches for...
5
by: AJ | last post by:
I'm writing my own little shopping cart system and am having a slight problem at the final hurdle. Visitor hits the site and once they add to their cart a row is created in a table with the...
4
by: Diamondback | last post by:
I have two tables, WIDGETS and VERSIONS. The WIDGETS table has descriptive information about the widgets while the VERSIONS table contains IDs relating to different iterations of those widgets...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
3
by: auron | last post by:
Hi there, I have a really stupid and banal problem with showing the results of a MySQL query in PHP, preciselly with MySQL count() function that gives to a variable in PHP the result. NOTE:...
6
by: loga123 | last post by:
I am using asp.net 2.0. I want to get the results of a sql query into an array at run-time. Number of records returned varies each time.....so I want to declare the dimensions of array runtime...
3
by: tom_b | last post by:
Hi, hope I can explain this clearly. I have the following query and results, no problems here: $query = 'SELECT SUM(ed) AS ed, SUM(ted) AS ted, SUM(tom) AS tom FROM week '; $result =...
4
by: bb nicole | last post by:
BElow is my php code for candidate search, it have 4 criteria which is academic background, functional experience, preferred location and languages ability. but it show yhe blanks page.. Emm, is it...
2
by: tech | last post by:
Hi, I want to create a map of named events from a const array. eg std::map<std::string, HANDLEthis needs to be intialised so that initially it will be contain the names of the all the events...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.