Results 1 to 9 of 9
  1. #1
    mlrucci is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2018
    Posts
    202

    vba to check if subform open in navigation form

    Hello all,
    I am attempting to check and see if a sub form in a navigation form is open. I am using

    Code:
    If CurrentProject.AllForms([Forms]![frmNav1]![frmNav2].[Form].[subfrm]).IsLoaded = True Then 
            MsgBox ("test")
    End If
    The sub form is 2 navigation forms deep. Usually when I refer to a control with in that form, I go to the control in the form because the system sees the form as a control. Example: [Forms]![frmNav1]![frmNav2].[Form].[ctl], but for this purpose, I do not want to check for the control inside the sub sub form. With that being said and that I know navigation forms are not preferred, this is what I have and do not want to redo the whole db. I know I am overlooking something ridiculous, but could use some insight.



    Thank you!

  2. #2
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    My guess is that you'll have to post a sample db with said forms or at least clarify if those are the real form names that you created. I had a quick play and couldn't even get a nav form on a nav form to set up correctly.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    mlrucci is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2018
    Posts
    202
    Micron, thank you for your response. I have built a very simple example of what I am looking for. I know it is something stupid I am missing.

    TestSubOpen.accdb

    Thank you

  4. #4
    Micron is online now Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    If memory serves, subforms are not part of the collection of open forms thus I suspect they are never "loaded" such that you can test using Application.AllForms reference. Therefore it seems you would have to refer to a control on the sub sub by using
    Code:
    Forms("frmNavMain").[navigationsubform].form.[navigationsubform].form.controls("cmdPopup").caption
    and trap the error that will result in trying to retrieve a property or value of something on the form if it isn't "loaded" into the navigation form.

    EDIT- turns out that the reference is simpler; e.g.
    Currentproject.AllForms("subfrm2").Isloaded but the answer is False, so it is as I suspected. Subforms are not "loaded" into the Forms collection.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    mlrucci is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2018
    Posts
    202
    Thank you for the insight. Sometimes it can be so frustrating. For those of you that need to do the above, I came up with a "band-aid" solution. I assigned a number to the each of the sub forms in the navigation form. I wrote code to look for the OpenForm number and went from there. Know it isn't the best solution, but it works, and my brain can finally shut down..lol Appreciate the help!

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Assign number where, look for where? Would you like to share the 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.

  7. #7
    mlrucci is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2018
    Posts
    202
    I simply created an unbound txt box with default number for each of the forms I need to check to see if open. Then had the system look for that number and used a case statement. Know it isn’t the best solution, but it worked. Nothing complex, just a work around.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    So one UNBOUND textbox and code populates it with a number when navigation button is clicked?
    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.

  9. #9
    mlrucci is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Apr 2018
    Posts
    202
    Yep. It is difficult working with the navigation forms as some things are just not the same. Have to be creative and unconventional at times

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Check if subform is open
    By mlrucci in forum Programming
    Replies: 8
    Last Post: 08-26-2021, 08:25 AM
  2. Open navigation form to specific ID
    By mlrucci in forum Forms
    Replies: 3
    Last Post: 12-18-2019, 05:16 PM
  3. Replies: 4
    Last Post: 11-06-2014, 05:35 AM
  4. Replies: 12
    Last Post: 10-23-2014, 02:08 AM
  5. Replies: 2
    Last Post: 02-26-2010, 08:14 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