Results 1 to 4 of 4
  1. #1
    Sebbers is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    3

    Referencing subform control from a main form (using an embedded macro)

    Hi,

    I have read about and tried extensively to reference a subform control from another form but to no avail. I hope someone can help.



    Name of main form is frmMembers
    Name of subform is frmMembersHistory (I' m using Design View/Other tab/Name and not Design View/Data tab/Source Object), which, as I understand, is the correct name to reference the subform from the main form.

    I have a button on the main form, which is trying to set the Enabled property of a control on the subform to False.
    I am using an embedded macro in the On Click event of this button and I am typing the following in the macro:

    Control Name Forms!frmMembers!frmMembersHistory.Form!Membership CategoryID
    Property Enabled
    Value False

    I have tried umpteen varaitions of this with [] and without and guess what ... I get the same 32004 error.

    Hope someone can shed some light.

    Many thanks,

    Seb

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You are correct that you want the name of the control, not the name of the form itself, if they're different. That looks okay, but try

    Forms!frmMembers!frmMembersHistory.Form.Membership CategoryID

    What is the text of the error, if you still get it?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Sebbers is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    3
    Hi Paul,

    Many thanks for your suggestion but it still does not work.
    The error is the same one I get every time:

    The control name "Forms!frmMembers!frmMembersHistory.Form.Membershi p CategoryID" is misspelled or refers to a control that does not exist.

    I have managed to get it to work with the SetValue command in the embedded macro:

    Item [Forms]![frmMembers]![frmMembersHistory].[Form]![MembershipCategoryID].[Enabled]
    Value False

    This is great from my point of view but it bugs me because I should be able to use SetProperty.

    As an alternative I also tried the following in the order below and I got no error:

    GoToControl frmMembersHistory
    GoToControl MembershipCategoryID

    but when I then added:

    SetProperty (all sorts of combinations of trying to reference MembershipCategoryID)

    the same error came up.

    I'm begginning to wonder whether:

    a) you cannot use the SetProperty to reference a control in a subform from another form.
    b) we've both got the wrong syntax (and I do not believe that for a minute)
    c) there is a bug with SetProperty when trying to reference a control in a subform from another form.

    Look forward to reading your thoughts or anyone elses.

    Thanks

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I don't use macros, but if you want to post the db I'll play with it and see if I can make it work.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 10
    Last Post: 02-20-2013, 07:04 AM
  2. Replies: 2
    Last Post: 09-13-2012, 12:25 PM
  3. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  4. Subform in a Tab Control on a Main form
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 01-08-2011, 12:31 PM
  5. Linking Subform Control to Main form
    By KWarzala in forum Forms
    Replies: 1
    Last Post: 03-13-2010, 08:32 PM

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