Solved

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

Posted on 2014-11-22
6
190 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 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

739 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