Results 1 to 5 of 5

Thread: Passing Arrays around Classes and subs

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Passing Arrays around Classes and subs

    Access 2003 - VBA module (form) and Class module

    Hi,

    Simple enough, I have an array on a form, and I want to pass it to a class. Problem is I haven't done this in a while and I cannot seem to get a reference working yet.

    The class property I am using is Let and has a variant type. The array on the form is two dimensional and is a string.

    I am getting error 13 - wrong data type.

    Can someone please point me in the right direction as my brain has died...
    (Due to a wrong filename this morning stopping my FTP connection reading local files correctly - found and fixed that, but this is just plain annoying)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Passing Arrays around Classes and subs

    you will need to convert you string array to variant array of strings

    probably won't be able to "convert" the array, so you will have to copy the elements into a new array of variant type

    pete

  3. #3

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Passing Arrays around Classes and subs

    Hmmm - I knew the arrays were useful and I recall (vaguely) that I had this problem before. Not exactly what I wanted to do, but I guess I have no choice.

    All I wanted was a reference to the array held on the form (or module) and then I can nuse the code in the class to pull the data I need from it. Not possible huh?

    I'll have another experiment and see.

    Thanks for the reply


    Edit:
    I have tried a simple one to another referenced array - and it works !!
    This is only between subs in the same module though, and I have a feeling Classes screwed that up a little. I'll post back in a while.
    Last edited by Ecniv; Jun 27th, 2005 at 09:50 AM.

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Passing Arrays around Classes and subs

    can't you just use (declare) a variant array to start with?

    some arrays can be converted but after doing some reading on it it is not very many and i'm not sure which

    pete

  5. #5

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Passing Arrays around Classes and subs

    Weirdly it is now working from form module to class.. Although I have shifted the Array to a module and made it public, the pointers are still variants and appear to be referencing the array as required.

    Thanks for the reply

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

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