Solved

Set a subforms allowadditions property based on a value in a form

Posted on 2007-11-29
4
399 Views
Last Modified: 2013-11-28
I want to set the allowadditions property of [frmSubForm] to FALSE if a value of a combo [mycombo] in the parent form [frmMain] is "Ordered"

If the user changes this combo (to "Not Ordered") then the allowadditions property gets re set to TRUE.

If the user changes the combo (back to "Ordered") then the allowadditions property gets re set to FALSE.
0
Comment
Question by:AbacusInfoTech
  • 2
  • 2
4 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 20377704
Use VBA in myCombo's After update event:

Private Sub MyCombo_AfterUpdate()
       If me.MyCombo = "Ordered" THEN Me.frmSubform.form.AllowAdditions = False
       If me.MyCombo = "Not Ordered" THEN Me.frmSubform.form.AllowAdditions = True
End sub

You also need to place this in the form's current event so that the subform will have the property set correctly  as the user scrolls through records.
0
 
LVL 1

Author Comment

by:AbacusInfoTech
ID: 20378035
Thanks, you got me there.

Just had to tweak:

Private Sub MyCombo_AfterUpdate()
       If me.MyCombo.Value = "Ordered" THEN Me.frmSubform.form.AllowAdditions = False
       If me.MyCombo.Value = "Not Ordered" THEN Me.frmSubform.form.AllowAdditions = True
End sub
0
 
LVL 61

Expert Comment

by:mbizup
ID: 20378067
Glad to help out :-)
I'm suprised you needed the ".Value".  I use the exact syntax I posted routinely.  I use access 2003 where ".value" is the default property.  Your question tags state Access 2000.  I wonder if that accounts for the difference?
0
 
LVL 1

Author Comment

by:AbacusInfoTech
ID: 20378413
I am using 2000... and I tried without .value so I guess 2003 may be different.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

785 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