Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why does my subform remain enabled after I disable it?

Posted on 2011-02-10
21
Medium Priority
?
434 Views
Last Modified: 2013-11-28
I have a main form (FORM_ED) and a sub form (HH_subform).
I want to disable certain command buttons on the main form
and the entire sub form depending upon the value of the field
CHECKED that is on the main form.  SO I put the following code
in the main form's current event handler:

Private Sub Form_Current()
If Me.CHECKED = True Then
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = False
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = False
    Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = False
    [HH_Subform].Enabled = False
Else
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = True
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = True
    Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = True
    [HH_Subform].Enabled = True
End If
End Sub

The problem, however, is that whereas all of the command
buttons are disabled when the value of CHECKED is TRUE,
the subform remains enabled or at least I can still enter data
into it.  How do I prevent the user from being able to enter data
into the subform when the value of CHECKED is true?
0
Comment
Question by:sib_user
[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
  • 9
  • 6
  • 3
  • +2
21 Comments
 
LVL 75
ID: 34865103
s/b working:

Me.[HH_Subform].Enabled = False

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34865121
make sure that you are using the subform name and not the name of the source object


me.[nameofsubform].enabled=false
0
 
LVL 31

Expert Comment

by:Helen Feddema
ID: 34865134
Also, setting them to Locked = True might be a better approach.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 40

Expert Comment

by:als315
ID: 34865181
Form have no .Enabled property
You can make it unvisible with
.visible = false
or disable all edits etc. with:
.AllowAdditions = False
.AllowDeletions = False
.AllowEdits = False
0
 
LVL 75
ID: 34865221
"Form have no .Enabled property"
It's a Sub Form Control, which does have an Enabled property.

mx
0
 

Author Comment

by:sib_user
ID: 34865311
mx, capricorn1, Helen_Feddema,
I've tried all of your suggestions and am still able to enter data into the subform.  

als315,
The subform does have an enabled property and in fact doesn't have any of those properties you mentioned.

I will post the app shortly and perhaps somebody may be able to make some sense of why the subform
remain enabled.
0
 
LVL 40

Expert Comment

by:als315
ID: 34865528
You are correct, there is difference between subform control and subform.
0
 

Author Comment

by:sib_user
ID: 34865565
Here is the app.

Click on the first button on the main menu to bring up the offending page.
VISITATION3.mdb
0
 
LVL 75
ID: 34865642
Need the VBA Password ....

mx
0
 

Author Comment

by:sib_user
ID: 34865657
Thought I took that off.  Its scouser.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34865661
i commented some codes in the load event of the form and make the check box visible so you can see, this is working
VISITATION3.mdb
0
 
LVL 75
ID: 34865748
The Line of code I commented out has a problem. When commented out, it's working fine - subform is disabled.

Private Sub Form_Current()
If Me.CHECKED = True Then
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = False
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = False
   '' Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = False ' *****
    Me.HH_Subform.Enabled = False
Else
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = True
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = True
    Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = True
    Me.HH_Subform.Enabled = True
End If
End Sub
0
 

Author Comment

by:sib_user
ID: 34865752
capricorn1,

I saw what you did but don't understand why it has the effect that it does.  Why does the visibility of the CHECKED control affect whether the subform is disabled or otherwise?
0
 
LVL 75
ID: 34865761
I also had to comment out code in On Load because of missing reference (in A2010) to calendar control.  

mx
0
 
LVL 75
ID: 34865814
"Thought I took that off."
Odd ... because VBA editor opens fine, but if I go to Tools>>References (again in A2010) ... then it asks for the password!  weird.

"Why does the visibility of the CHECKED control affect whether the subform is disabled or otherwise?"
I got it working simply by commenting out the On Load code (with Environ) because of the reference issue ... and the other line in the Current event that was causing an error. No other changes.

mx
0
 

Author Comment

by:sib_user
ID: 34865884
Mx,
I understand why your solution works.  I had deleted the command button SAME_BUILDING_NEW_VACANT_HOUSEHOLD and failed to delete all references to it.  

Rather strange behavior on the part of MS Access to simple stop executing without giving some feedback.  

Maybe this warrant some more points, but is it possible to get Access to complain about these bad references?
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 34865922
OK ... I'm on my A2003 system now.  The *only* change necessary to make this work ... form your original is shown below:

Private Sub Form_Current()
If Me.CHECKED = True Then
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = False
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = False
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = False
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = False
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = False
  ' Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = False  ' does not exist
    Me.HH_Subform.Enabled = False
Else
    Me.[DIFFERENT_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_HOUSEHOLD].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_BUILDING].Enabled = True
    Me.[DIFFERENT_BUILDING_NEW_VACANT_DWELLING].Enabled = True
    Me.[SAME_BUILDING_NEW_BUSINESS].Enabled = True
    Me.[SAME_BUILDING_NEW_DWELLING_AND_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_SAME_DWELLING_NEW_HOUSEHOLD].Enabled = True
    Me.[SAME_BUILDING_NEW_VACANT_DWELLING].Enabled = True
  ' Me.[SAME_BUILDING_NEW_VACANT_HOUSEHOLD].Enabled = True  ' does not exist
    Me.HH_Subform.Enabled = True
End If
End Sub
VISITATION3-MX01.zip
0
 
LVL 75
ID: 34865942
Note ... no Reference issues on my A2003 system, so I did not need to comment out the On Load code ... just those two lines above.  

This control  SAME_BUILDING_NEW_VACANT_HOUSEHOLD  does not exist ... but some similar names do.

mx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 34866044


<I saw what you did but don't understand why it has the effect that it does.  Why does the visibility of the CHECKED control affect whether the subform is disabled or otherwise?>

i t does not have any effect. as i've stated above
so you can see the condition or state of the check box
0
 
LVL 75
ID: 34866121
In the version I downloaded @ http:#a34865565 ... CHECKED was already visible !  

mx
Capture1.gif
0
 

Author Closing Comment

by:sib_user
ID: 34866368
Thanks for all of your comments. As usual when I ask a question on MS Access of EE the responses are prompt and helpful.

Thanks again!!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

604 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