Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,789
    IIRC when using that reference syntax you need quotes around the form name. You must keep the brackets because you allow spaces in your names. Many of us simplify code by not doing so.

  2. #17
    Kudos is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2017
    Location
    Toronto, ON
    Posts
    29
    I guess you kinda did, but you referred to running the Events form in a tab control. That tab control must be on a parent form, so I knew the parent existed.

    I can't really comment on the Member/Activities situation without more detail, but go with your gut and test out your guess! This page is an excellent reference for figuring out exactly how to refer to controls on forms and subforms: http://access.mvps.org/access/forms/frm0031.htm

    Here's one way to test for the parent form - this is just checking if that particular form is open though, which is probably close enough logic for your purposes. I haven't tested this at all, just guessing at the code. Found here: https://stackoverflow.com/questions/...nt-form-exists

    Private Sub Role_GotFocus()
    Dim MyEvent As String

    If Not CurrentProject.AllForms("Manage SCATeam").IsLoaded Then
    MyEvent = [Forms]![Manage SCATeam]![NavigationSubform].[Form]![Event_Type]
    Else
    MyEvent = [Forms]![Events]![Event_Type]
    End If

    Me.[Role].RowSource = "SELECT [Role_Act].[Role], [Role_Act].[Ev_Type]" & _
    " FROM [Role_Act]" & _
    " WHERE InStr([Role_Act].[Ev_Type], " & MyEvent & " )" & _
    " OR [Role_Act].[Ev_Type] = 'All';"
    End Sub

    And for your Contiguous Form/Parent Form issue, try: Set rst = Forms("Activities Ev Subform").Recordset

  3. #18
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    With my initial question related to this topic, I had attempted to use the Parent property of the sub-form, with which I was vaguely familiar. I think I had written it as Me.Parent.[Control], but Access choked on it. I am not sure now, but I may have included Form somewhere in the statement.

    Then I found references to using explicit contexts to reference other forms found here.
    https://support.office.com/en-us/art...6-6b24b5b14400
    That led to this whole dialog of dealing with the full form hierarchy to reference a parent form.

    As I was revisiting this topic, I thought there really should be a simpler way to reference a parent form, directly from the sub-form, with a relative reference. I looked up the Parent property, which works for both forms and reports. I saw that it can be used to reference the parent form of the sub-form directly from the sub-form, as in: Parent.[Event_Type]. Apparently, I should not have included the Me in my original attempt.

    So, I replaced the complicated, hard-coded, full hierarchy expression in the sub-form control with Parent.[Event_Type], andit works as it should. Not only that, but it will work in whichever context I open the Events form.

  4. #19
    WCStarks is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2016
    Posts
    314
    Thank you.

  5. #20
    Kudos is offline Novice
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2017
    Location
    Toronto, ON
    Posts
    29
    Oh that's much tidier. Very nice!

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

Similar Threads

  1. Control to VBA code
    By Thompyt in forum Programming
    Replies: 2
    Last Post: 04-21-2016, 05:10 PM
  2. Replies: 6
    Last Post: 06-11-2014, 01:00 AM
  3. code to apply control formatting
    By tariq1 in forum Programming
    Replies: 3
    Last Post: 07-21-2012, 12:36 PM
  4. Code not working with tab control
    By pg13Reader in forum Programming
    Replies: 4
    Last Post: 12-13-2011, 06:30 PM
  5. Tabular Control Code
    By benthamq in forum Programming
    Replies: 6
    Last Post: 09-12-2011, 04:16 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