Solved

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

Posted on 2014-11-22
6
189 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
Independent Software Vendors: 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!

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

749 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