Solved

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

Posted on 2014-11-22
6
184 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
  • 3
  • 2
6 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 450 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 47

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 50 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 57
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 57
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now