Results 1 to 2 of 2

Thread: Arrays

  1. #1
    Guest
    When you open a database using DAO you can refer to fields using recordset.fields("FieldName"). Is it possible to create an array that would use String instead of Integer?
    ie;
    instead of
    Code:
    ReDim Preserve Marek(1)
    I would use
    Code:
    ReDim Preserve Marek("Marek")
    and then access it using "Marek" as array index?

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The DAO 'arrays' are not arrays. They are Collections, which are accessed by a 'key', usually a String value:
    Code:
    Dim MyCol As New Collection
    Private Sub Form_Load()
        MyCol.Add "Item 1", "My item"
        MyCol.Add "Item 2", "A different item"
        MsgBox MyCol("My item")
    End Sub
    They basically deal in Variants all the time, so you can add an item of pretty much any type, although there may be restrictions on indices.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width