Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 602929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:52:33+00:00 2026-05-13T16:52:33+00:00

I’m using VBA in an Access application and I would like to have a

  • 0

I’m using VBA in an Access application and I would like to have a n-tuple object that contains values of different data types. Then I would like a collection of those objects.

If I was doing this in javascript it would look like:

var myStructure = {
   name: "blah"
   age: 33
   moreStuff : "test"
};

And then I would need a collection of myStructure. How can I best accomplish this in VBA?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:52:34+00:00Added an answer on May 13, 2026 at 4:52 pm

    You can define your own variable type with code such as:

    Public Type T_Person
        name as string
        dateOfBirth as date
        ....
        email() as string (*)
        ....
    End type
    

    You can then declare a T_person type in your code with:

    Dim currentPerson as T_Person
    
    currentPerson.name = myName
    currentPerson.dateOfBirth = myDate
    currentPerson.email(1) = myFirstEmail
    ....
    

    (*) I do not remember the details for declaring arrays in such circumstances. You might have to determine array’s length when defining the variable. Please check help.

    The same result can also be reached by declaring a class module named, for example, "Person". In this class module, you’ll be not only able to follow the objet properties (such as name, dateOfBirth, etc), but also object events (initialisation and deletion). You’ll be also able to create methods on this object. You code would then look like:

    Dim myPerson as Person
    
    set myPerson = New Person
    
    myPerson.name = myName
    myPerson.dateOfBirth = myDate
    
    if myPerson.age > 18 then  (*)
        'the guy is an adult'
        myPerson.createAccount
    Else
        'the guy is not ...'
    Endif
    

    (*) Here, age is a calculated proerty of your object, available when dateOfBirth is not null. Please google "VBA class module" to find different examples for the implementation of a class module in VBA.

    Now, if you want to manage a collection of similar "objects" (here, Persons), you will have to go through the creation of a class module for your objects collection (a "Persons" class module for example) and make use of the "Collection" objet available in VBA. You will then end with 2 different class modules: Person (will hold each person’s detail), and Persons (will hold the collection of Persons). You’ll then be able to have code like this:

    Public myPersons as Persons    'at the app level, 1 main collection'
    
    myPersons.add ....              'adding a new person to your collection'
    
    myPersons.count ...             'counting number of persons in myPersons'
    

    Please google on "VBA collection object" for examples on Collection management in VBA. Check my code proposal, as this was written on the fly, and without VBA help file.

    The "Class" solution is clearly more powerfull, but more complex than the "Type". Go for it if you need it. It is definitely worth the pain!

    PS: I am not very happy with my namings here, as this can lead to very confusing code when dealing with the myPersons collection and myPerson instance of o Person object. I’d advise you to find a more obvious one, like "PersonCollection" and "Person", or even "Individual"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.