Does anyone know if MS Access supports storing data in arrays? My version is 2000. Thanks.
6 2733
Does anyone know if MS Access supports storing data in arrays? My version is 2000. Thanks.
Hi
Yes it does in VBA - Dim MyArray(10) As Integer
Or more advanced with regard to your question about data - Dim arData As Variant
-
-
arData = myRecordset.GetRows()
This is probably a stupid question, but I'm used to storing data explicitly in arrays. Pseudo-wise, the table would be defined something like --
create table XYZ
column name
column phone
column month occurs 12 times
Then you would insert something like this --
Insert into table XYZ
(name, phone, month)
values
(
'Scott',
'555-1234',
1,2,3,4,5,6,7,8,9,10,11,12
)
From your example I see the programming aspect of arrays, but not the table aspect.
This is probably a stupid question, but I'm used to storing data explicitly in arrays. Pseudo-wise, the table would be defined something like --
create table XYZ
column name
column phone
column month occurs 12 times
Then you would insert something like this --
Insert into table XYZ
(name, phone, month)
values
(
'Scott',
'555-1234',
1,2,3,4,5,6,7,8,9,10,11,12
)
From your example I see the programming aspect of arrays, but not the table aspect.
Right and if you want to query this data directly you would use a recordset which would, in fact, hold an array. If you wanted to move the data to an array you would use the GetRows() method of the recordset which means you would have a 2 dimensional array
ar(columns, rows)
ar(0, 0) would be 'Scott'
ar(1, 0) would be '555-1234'
ar(2, 0) would be 1
and so on
I think I see. So I can't explicitly define columns in Access with a subscript? For instance --
column1, column2, ...column12
rather than --
column(1), column(2), ...column(12)
?
And then in VB (pseudo code) --
select column1, column2, ...column12 from table
into myarray(1), column(2), ...column(12)
Hopefully I've explained it better. Thanks.
I think I see. So I can't explicitly define columns in Access with a subscript? For instance --
column1, column2, ...column12
rather than --
column(1), column(2), ...column(12)
?
And then in VB (pseudo code) --
select column1, column2, ...column12 from table
into myarray(1), column(2), ...column(12)
Hopefully I've explained it better. Thanks.
In vb you will define a recordset object and use a select statement to populate the object from a table or set of joined tables. Then, in your code, you will use the recordset as an array with a particular syntax: - Dim MyRecordset As Recordset
-
Dim stSQL As String
-
Dim lngValue As Long
-
Dim stValue As String
-
-
stSQL = "SELECT ColumnName1, ColumnName2 etc FROM MyTable"
-
-
Set MyRecordset = CurrentDb.OpenRecordset(stSQL)
-
-
lngValue = MyRecordset("ColumnName1")
-
stValue = MyRecordset("ColumnName2")
etc
These values only refer to the first row. If you need to step through the rows for example: - Do While Not MyRecordset.EOF
-
lngValue = lngValue + MyRecordset("ColumnName1")
-
MyRecordset.MoveNext
-
Loop
-
-
MsgBox "Total: " & lngValue
Working with recordsets is usually much more involved than this and I have kept it as simple as I can
You can use an index with the recordset - lngValue = MyRecordset(1)
But this is very bad programming practise and not good for your sanity
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Canonical Latin |
last post by:
"Leor Zolman" <leor@bdsoft.com> wrote
> "Canonical Latin" <javaplus@hotmail.com> wrote:
>
> > ...
> >But I'm still curious as to the rational of having type
>...
|
by: Matteo Settenvini |
last post by:
Ok, I'm quite a newbie, so this question may appear silly. I'm using
g++ 3.3.x.
I had been taught that an array isn't a lot different from a pointer
(in fact you can use the pointer arithmetics to...
|
by: JezB |
last post by:
What's the easiest way to concatenate arrays ? For example, I want a list of
files that match one of 3 search patterns, so I need something like
DirectoryInfo ld = new DirectoryInfo(searchDir);...
|
by: Michel Rouzic |
last post by:
It's the first time I try using structs, and I'm getting confused with
it and can't make it work properly
I firstly define the structure by this : typedef struct { char *l1; int
*l2; int Nval; }...
|
by: Rob Griffiths |
last post by:
Can anyone explain to me the difference between an element type and a
component type?
In the java literature, arrays are said to have component types, whereas
collections from the Collections...
|
by: Rene Nyffenegger |
last post by:
Hello everyone.
I am not fluent in JavaScript, so I might overlook the obvious.
But in all other programming languages that I know and that
have associative arrays, or hashes, the elements in...
|
by: Robert Bravery |
last post by:
Hi all,
Can some one show me how to achieve a cross product of arrays. So that if I
had two arrays (could be any number) with three elements in each (once again
could be any number) I would get:...
|
by: Doug_J_W |
last post by:
I have a Visual Basic (2005) project that contains around twenty
embedded text files as resources. The text files contain two columns
of real numbers that are separated by tab deliminator, and are...
|
by: mike3 |
last post by:
(I'm xposting this to both comp.lang.c++ and comp.os.ms-
windows.programmer.win32
since there's Windows material in here as well as questions related to
standard
C++. Not sure how that'd go over...
|
by: weaknessforcats |
last post by:
Arrays Revealed
Introduction
Arrays are the built-in containers of C and C++. This article assumes the reader has some experiece with
arrays and array syntax but is not clear on a )exactly how...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
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...
|
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...
|
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,...
|
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: 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...
|
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...
| |