Help!! Passing array to another forms listbox...

themanof83

Registered User.
Local time
Today, 04:40
Joined
May 1, 2008
Messages
73
Okay, I have been trying for a while now but am begining to get repeatingly lost and my code is up in the air at the minute!

Basically, I have an on-click command that uses the .FileSearch Property to locate specific files in a specific directory. This works perfectly.
If there is more then 1 file found within that directory then I have a form that opens with a listbox that I want to populate with the files found.

My problem is that I don't know how to pass the found files array (ArrFilesfound(i)) to the listbox in the other form. I would like this to happen in the Form_Open command of the form.

Here's the code from the on_click command:

Code:
            'Execute the search....
            If .Execute(SortBy:=msoSortByFileName, _
                SortOrder:=msoSortOrderAscending) > 0 Then
                
                If .FoundFiles.Count > 1 Then
                    
                    FilesFoundCount = .FoundFiles.Count
                                        
                    For i = 1 To .FoundFiles.Count
                        ArrFilesfound(i) = .FoundFiles(i)
                        Debug.Print ArrFilesfound(i)
                    Next i
                    
                    DoCmd.OpenForm "Multiple", acNormal, , , , acDialog

                End If
            End If

It is ArrFilesfound(i) that I want the Form_Open function of my other form (Multiple) to pick up. Then populate the listbox with the values.

Thanks in advance.
 
Thanx JANR. Whilst I have implemented the code correctly I am having the same trouble with the .AddItem method, as I always have.... it simply doesn't want to work!
 
Have you tried to delcare the ArrFilesfound(i) as a global variable and not specific to the form you are using?
 
JPearson, my knowledge of doing anything 'globally' or outside any private function is very limited. And this is the very reason I'm struggling.... please tell me how.
 
It can be but as far as using an array this should not cause a problem. You can redim from the sub if it is dynamic and it will carry the data between forms and modules during a run.
 

Users who are viewing this thread

Back
Top Bottom