Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479

    Passing Property to Form

    In form called frmER Declarations I have
    Private filenames As Variant
    Then
    Code:
    Public Property Let fnArray(x As Variant)
        filenames = x
        MsgBox UBound(filenames)
    End Property
    From a module
    Code:
     Form_frmER.fnArray = files
     DoCmd.OpenForm "frmER", acNormal, , , , acDialog
    Should the Open Form command should be before or after the assignment of Files.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    What happens when you run code?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Both ways seem to work, but a type mismatch error came up and I wanted to be sure that first part was correct.
    How would you pass a array to a Form ?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I have never coded custom properties for anything.

    I have just passed array object as procedure argument or public/global declared variable.

    Type mismatch for both approaches?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    > Type mismatch for both approaches?
    Yes, although the error might be correct. No problem if I pass it as a string.
    I have this vague recollection if you use Form_ type addressing and the Form isn't Open, it will Open.
    I was wanting to nail down the correct order before looking further.
    Access is so b complicated if you haven't used it for a while....


  6. #6
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    you need to Declare your variable, filenames As Variant also.

  7. #7
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    OK, jo. Isn't that done in the declarations?

  8. #8
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    sorry, did not see that.
    on this code:
    Code:
    Form_frmER.fnArray = files
    is files an Array?
    because on the code you are Msgboxing it's dimension (Ubound).

  9. #9
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    files is a variant holding 2 items (while testing).
    But I'm a bit snookered how this is working.
    Code:
    Form_frmER.fnArray = files
    This runs the Form Load Event. But I don't want that happening until
    Code:
     DoCmd.OpenForm "frmER", acNormal, , , , acDialog
    How can I pass that property to the Form without Opening it ?
    Because I can't do it after the Form opens. Its acDialog.

  10. #10
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2021
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,741
    Have a look at this discussion. WGM had comments too!

    Solved - Passing values to popup using OpenArgs | Access World Forums

  11. #11
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Understood Dave, split OpenArgs. I can see how that would work. I can also pass my array with a global variable as June said.
    But why can't I use Property Let. Isn't that what it's for ?
    Annoying i have used it in the past, but can't remember exactly how.

  12. #12
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    you can get rid of global variable by opening your form "normaly" and set the property.
    later you set its Modal property to True:
    Code:
    DoCmd.OpenForm "frmER"
    With Forms!frmER
        'pass the array
        .fnArray = files
        'make the form Modal
        .Form.Modal = True
    End With

  13. #13
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Ah, thank jo. That is working. Don't know why but everything I tried turned to custard.
    I think my Type Mismatch problem was multiple openings of the Form, and the variable wasn't seen by the current instance.
    Yours was a good solution..

  14. #14
    Middlemarch is offline Competent Performer
    Windows 10 Access 2019
    Join Date
    Mar 2015
    Posts
    479
    Jo I did have that working, but there was a noticeable lag while the array passed was processed.
    So (and this is new to me) I used the form open event to do everything. Then the form opens with it's Listview control already populated.
    But I need to have the files array available in the Form Open event. I need to revert to a Global variable to do that ?
    I did try .Visible= False in that with block but that wasn't good, the screen flash was worse than the delay

  15. #15
    jojowhite's Avatar
    jojowhite is offline Competent Performer
    Windows 11 Access 2021
    Join Date
    Jan 2025
    Posts
    434
    how do you Populate the "files" array?
    and on frmER, how do you Populate the listbox (are you using Listview, and ActiveX)?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-09-2021, 05:52 PM
  2. Replies: 17
    Last Post: 02-25-2018, 02:37 AM
  3. Passing Data From One Form to Another Form
    By ETCallHome in forum Forms
    Replies: 6
    Last Post: 03-12-2011, 12:53 PM
  4. Replies: 10
    Last Post: 09-27-2010, 08:06 PM
  5. Passing current form name to other form
    By owiec in forum Forms
    Replies: 2
    Last Post: 11-15-2009, 05:50 AM

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