Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I refer to a subform in order to change its properties?

Posted on 2014-11-22
6
Medium Priority
?
192 Views
Last Modified: 2014-11-22
How do I refer to a subform in order to change its properties?  1) When I first open the main form, I would like subformA to show no records and not accept new records.  2) Once a record is selected in  subformB, I would like subformA to accept new records.  
Thanks, Saleve
0
Comment
Question by:Saleve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 1800 total points
ID: 40459938
Saleve,

Forms![<main form name>]![sub form *control* name>].Form.<property>

 Note that you want the subform control name, which may or may not be the name you see in the database container.   For example, I always name my controls with a prefix and use "emb" (for embedded), so I might have this:

Forms![frmCustomer]![embfrmCustomerOpenInvoices].Form.AllowEdits = False

with:
frmCustomerOpenInvoices

  being the actual name of the form in the nav pane.

Jim.
0
 

Author Comment

by:Saleve
ID: 40459966
Hi Jim,
It half works.  When I use that notation to, for instance, make the sub form not visible on loading the main form, it works.  But when I use this code on the on "load" of the main form, edits are still allowed on the subform although I don't get an error:

Forms![Main]![embSubCategories].Form.AllowEdits = False

As I mentioned, I know that I am correctly referring to the subform because it works with .visible = false.



Saleve
0
 
LVL 48

Assisted Solution

by:Dale Fye
Dale Fye earned 200 total points
ID: 40459975
Actually, to hide the subform, from the main form the syntax would be:

me.embSubCategories.Visible = false

You would not refer to the actual subforms Form object, only to the subform control, as it sits on the main form.  They syntax you show above should work.  I'm guessing that there is some code in the subforms Current Event, or some other event on the subform that sets the AllowEdits property to true again.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 58
ID: 40459996
You need to watch the order of events, seems counter intuitive, but sub form initialization and loading comes before the main forms On Load event fires.

 With that said, what your doing should be working.  However you may need more than AllowEdits to achieve what you want.  For example, you may want to set DataEntry to true as well.

Jim.
0
 
LVL 58
ID: 40459999
There's also .AllowAdditions and .AllowDeletions

Jim.
0
 

Author Comment

by:Saleve
ID: 40460006
Hi Jim,
(I thought that I had posted a response to you but I screwed it up...)

Yes, I just realized that I was getting .AllowAdditions confused with .AllowEdits.

I'm just getting back to Access after a LONG hiatus and I am really rusty.  It's amazing how much one can forget after 10 years (and two kids).  Time to hit the books!

Thank again!
Saleve
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question