arrays
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Arrays

Arrays

resolvedResolved · Low Priority · Version 2003

replyReply Thu 22 May 2008, 09:31Delegate Jan said...

Jan has attended:
Access VBA course

Arrays

Hi,
just a quick question.
As we have not touched arrays on our training - how do they work? i.e. how do you compare set of values in an array to certain variable?
Thanks

For upcoming training course dates see: Pricing & availability

replyReply Fri 23 May 2008, 09:32Trainer Stephen said...

RE: arrays

Hi Jan

Thank you for your question

An array can be thought of as a virtual table that can hold multiple values.
You must first declare an array in the same way as you would declare a variable.

e.g

Dim myArray(5,6) as integer

Would declare an array of 5 "rows" and 6 "columns" that would contain integer data.

You can then set the different "cells" of the array equal to particular values

e.g

myArray(1,1) = 323

Sets the first row, first column value to 323.

To compare a set of values in an array to a variable you would normally cycle through the array checking each value against your variable

The following code cycles through each row and column and checks each value against a particualr variable and executes some code if a match is found

For i = 1 to 5

For j = 1 to 6

if myArray(i,j) = Variable then

EXECUTE CODE

End if

next j

next i


 

Please browse our web site to find out more about
microsoft access course and other Microsoft training courses.

Access tip:

Action queries

Unlike select queries you cannot use action queries as a data source for the use with forms or reports,as they do not return a dataset that can be read.

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard