Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2004, 01:16 PM
Authorized User
 
Join Date: Apr 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Array column

Hi, All:
Can I use Array column in Access? I have a variable which will have multiple vaules, I want to store this in one column, anyone have a good idea?
thanks

 
Old June 24th, 2004, 01:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

The short answer is 'no'.

The long answer is that multivalued fields are a bad idea in relational database design. In db normalization nomenclature they are called "repeating groups", and a table that contains repeating groups is not even in first normal form (1NF). The definition of first normal form is, essentially, "no tables in your schema contain repeating groups." Ideally, all of the tables in your db schema should achieve at least 3rd normal form. Normalization aside...

The way to handle your multivalued field (e.g., multiple telephone numbers) is to remove it from your primary table and place it in a new table that has a one-to-many relationship to your primary table (e.g., Clients). Add a forieng-key field to your new table (many-side of the relationship) that relates to the primary-key field of your primary table.

If you want to list your related multiple values, use a query to bring them together.

Hope that makes some sense.

Bob

 
Old June 26th, 2004, 02:32 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello reindeerw,
What Bob said was correct, but of course, there are exceptions to every rule.
Without asking your purpose for desiring an array column, I will offer a way to input the values of an array, into a single field.
..assuming this is your question...
Dim x as Integer
Dim sArray as String
For x = 1 to aArray(Ubound)
If x <> aArray(Ubound) Then
sArray = sArray & aArray(x) & "; "
Else
sArray = sArray & aArray(x)
End If
Next x

Me.FieldName = sArray

This will update the immediate form, that has the focus & only one record.

Is this what your looking for?
Hope it helps, good luck!



 
Old June 26th, 2004, 04:40 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi reindeerw and DBoulos,

My apologies for the detour reindeerw, didn't mean to wander too far a field, and thank you for the code DBoulos. I just tweaked a couple spots.

Dim x As Integer
    Dim sArray As String
    Dim aArray(10) As String

    For x = 1 To UBound(aArray)
        If x <> UBound(aArray) Then
            sArray = sArray & aArray(x) & "; "
        Else
            sArray = sArray & aArray(x)
        End If
    Next x

    Me.FieldName = sArray

Best to all,

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convering a String Array to an Integer array nkrust C# 9 November 17th, 2010 12:02 PM
Go from 2d Array to 1d array without defining type OneQuestion General .NET 1 January 10th, 2008 11:13 AM
Multi-Column Array Search RollingWoodFarm Excel VBA 5 August 1st, 2006 06:45 PM
can i store array values in a column using sqlser anil_76781 SQL Server 2000 1 May 10th, 2005 04:35 AM
Passing php array values to javascript array gkrishna Pro PHP 0 November 6th, 2004 03:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.