Share via

MS ACCESS/Macro/Subform's Control

Anonymous
2016-09-28T20:10:25+00:00

Greetings, 

I'm trying to reference a subform's control from main form. I'm using (trying) a command button with macro to hide "Qty" control on subform (via SetProperty). I have not been able to solve the correct syntax. I'm clear that the subform is considered as a control itself. As a result I'm using syntax as such

Forms![Main forms name]![subforms control name].Form![Qty] 

I've found several several answers (syntax) on the topic and tried numerous versions of all. Still no success. Just to simplify, (in macro) I only enter [subforms control name] . And subform becomes hidden (via ..Visibility , No). 

As soon as I try to get to the subforms control (any of them), macro error appears. Something to the affect "names not recognized". 

I've stried for success on different computers (w/ access 2013) and several different access files and forms. NO success. Any suggestions?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2016-09-28T21:29:43+00:00

I would not use a macro for this myself, but I've experimented with one and get the same behaviour as you.  Are you obliged to use a macro, i.e. is this a 'web database'?  If not you should be able to do it with a single line of code in the command button's Click event procedure:

Me.[subform control name].Form.[Qty].Visible = False

Was this answer helpful?

0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Anonymous
    2016-09-29T06:03:47+00:00

    Thanks Tom!!

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2016-09-29T06:02:53+00:00

    Thanks so much Ken! Cheers!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2016-09-28T20:21:19+00:00

    To see if you have the right syntax, you could run the form, then hit Ctrl+G to go to the immediate window, where you can type a command such as:

    Forms![Main forms name]![subforms control name].Form![Qty].Visible = False

    and hit enter to see what happens.

    Was this answer helpful?

    0 comments No comments