Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 42
  1. #16
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Then I don't see an issue. This works to pass the name of an array variable to a function:
    Code:
    Call f_verify_value_in_Array("al" & i, i)
    What you want to do/to with it from there is unclear. It's best that you don't be too simplistic with code examples as their purpose is often not interpreted correctly thus suggestions don't apply. Best to be clear, precise and concise regarding what you have, need and are experiencing.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  2. #17
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    Micron, If you test the posted code You will verify that don't work, the parameters passed to function is a literal and not a array reference !

  3. #18
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I did test it, and based on your posts, it is what you asked for:
    from post #1
    I need to pass the name of an array to a function
    from post #6
    I need to pass the array name to function
    from post #15
    pass the name of an array to a function
    AND
    identify the name of this array
    I also gave you links on passing an array to a function, and advised you on being clear, concise, etc. If you can't do that, and can't even indicate whether or not you even investigated the links, I'm sorry but I cannot participate any more. My time is free, but not unlimited.
    Good luck!

  4. #19
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    Thank you for your help Micron, but I think you did not understand the reason for my doubts, John_G understood what I need and I'm happy about my writing, if no one had understood I would really worried.
    If you check the title of my post will understand my problem, I do not know the name of the array that need to pass to the function will be hundreds and hundreds of arrays, I need to dynamically assemble the name of array to pass as a parameter to the function.
    Disagree you also when asked to me put my real problem in the post, an example is much easier to understand than the whole code!
    In any case I appreciate your commitment, I am programmer for over 30 years, I have worked with Oracle PLSQL, FOCUS (mainframe), VB, Java, C ++, PHP, ASP and many other languages.
    I do not have proficiency in the English language and maybe this has generated your doubt, but I am very grateful for your support.

  5. #20
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The problem you are facing is that Access does not have a method of putting an array (variable) name into a string, and then referring to the array (variable) using the contents of the string.

    If your array names are all similar (aL1, aL2, aL3.....), then you could create a 2-dimensional array aL(i, j), where each row or column represents one of the original 1-dimensional arrays. It does not have to be a constant size - as long as you can determine the values of I and j, you can use a Redim statement to resize it.

    Then, to use your function, you could copy one row of the 2-D array to a 1-D array, and pass that 1-D array to the function.

  6. #21
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    John_G, I'll have many name of array, aL1 for example is name to refer a "a"rray "L"ine 1.
    I'll have "a"rray "C"olumn 2, "a"rray "P"ime "N"umbers, and etc.
    I think that I will change my code to use dictionary structure object, but sincerely I don't know the performance

  7. #22
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    Explore the usage of ParamArray declaration in Function Parameters. Find details in VBA Help Documents.

    You will find some details with examples here also:http://www.msaccesstips.com/2008/11/...vg-paramarray/

  8. #23
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Why do you need to call a separate function anyway? Why not just do all your coding in one Function?

    Function f_test()
    Dim i As Long

    aL1 = "01,02,03,04,05,06,07,08,09,10"
    aL2 = "11,12,13,14,15,16,17,18,19,20"
    aL3 = "21,22,23,24,25,26,27,28,29,30"
    aL4 = "31,32,33,34,35,36,37,38,39,40"
    aL5 = "41,42,43,44,45,46,47,48,49,50"

    For i = 1 To 5

    If aL(i) > 0 then
    "Array has data and Do Something"
    Else
    "Do Nothing"
    End If

    Next i

  9. #24
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    Hi Bulzie, thanks for your help.
    This is only a litle example, my code will have hundreds and hundreds of arrays and without standard in name.
    I need perfonce in my code, for this reason I'm using array, this code will interact million of times.

  10. #25
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Quote Originally Posted by mcarval22 View Post
    Hi Bulzie, thanks for your help.
    This is only a litle example, my code will have hundreds and hundreds of arrays and without standard in name.
    I need perfonce in my code, for this reason I'm using array, this code will interact million of times.
    Sorry maybe I'm just not understanding your process. I'm not saying get rid of your array, get rid of the call to the other Function and do it all in 1 Function.

  11. #26
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    I understood what you said, but it will be an enormous code with various conditions and difficult maintenance, and not be optimized and elegant.
    Almost all others languages that I know there is POINTER, what I need is to find it in VBA, especially for knowledge!

  12. #27
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    what I need is to find it in VBA
    A little web searching came up with these links, which discuss pointers in VBA:

    http://www.access-programmers.co.uk/...d.php?t=225415
    http://bytecomb.com/vba-internals-getting-pointers/
    http://www.codeproject.com/Articles/...n-Visual-Basic
    http://stackoverflow.com/questions/1...ference-in-vba

    However, I'm not sure you'll be any further ahead with that information. You still want to try to get the address of an array when you have the name of the array in a string variable, and I have not seen any reference as to how you might do that.

    You could I suppose build a 2-D index array which mapped array names (as strings) to memory locations, but that still leaves you with the issue of having to determine all those memory locations in the first place, and from what I can see, you could not do that in a loop - you would still need one line of code for each one.

  13. #28
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Try using parentheses around the variable like this:

    Dim vArray as Variant

    for i=1 to 5
    vArray = "aL" & i
    call f_verify_value_in_Array((vArray), i)
    next i

  14. #29
    mcarval22 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2016
    Location
    Brazil
    Posts
    19
    Hi Bulzie, this is one of the first tests that I did, doesn't work !

  15. #30
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should check out Chip Pearson's site:

    Passing And Returning Arrays With Functions
    http://www.cpearson.com/excel/Passin...ningArrays.htm

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA passing Array arguments to procedure
    By George in forum Access
    Replies: 2
    Last Post: 05-13-2015, 10:03 AM
  2. st deviation function on array
    By registoni in forum Programming
    Replies: 2
    Last Post: 09-09-2013, 04:00 AM
  3. Singly linked, dynamic array, or both?
    By kopbad in forum Database Design
    Replies: 9
    Last Post: 04-27-2012, 09:13 PM
  4. Replies: 3
    Last Post: 05-23-2011, 02:15 PM
  5. dynamic array for calendar
    By workindan in forum Programming
    Replies: 7
    Last Post: 11-12-2010, 01:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums