Solved

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

Posted on 2014-11-22
6
188 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

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 tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

808 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