arrays

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

Arrays

resolvedResolved · Low Priority · Version 2003

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

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


 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Deleting duplicate records from a table

You cannot delete records tables where there duplicate records. A way around this is to create a new table which wont hold the duplicates. and then deleting the old table.

1. Use a make-table query based on this table only. IMPORTANT - Ensure that you include all of the fields from your original table or you may loose data.

2. Open the query's property sheet by using VIEW, QUERY, PROPERTIES, and set the Unique Values property to Yes

3. Because you have selected the Unique Values to Yes when you run the query, Access creates a new table without duplicate records. You can now delete the old table and rename the new one.

View all Access hints and tips


Server loaded in 0.05 secs.