Inactivate a subform upon a choice.

  • Thread starter Faraz A. Qureshi
  • Start date
F

Faraz A. Qureshi

I have the Parent Form with a field "CaseType" ComboBox with choice like
"Business";"Personal"

I want the subform to become inactive if "Personal" is chosen on the parent
form AND the SubForm's field "Partners" to acquire the same value as of
Parent Form's field "Name".

Any idea/Event Code/Macro/guidance shall highly be obliged?
 
J

Jeanette Cunningham

This is untested.
First set the subform's field Partners, then disable the subform.

This code would go on the after update event for the combo.

If Not IsNull(Me.cboCaseType) Then
If Me.cboCaseType = "Personal" Then
Me.[SubformControlName].Form.Partners = Me.[NameOfNameField]
Me.[SubformControlName].Enabled = False

Else
Me.[SubformControlName].Enabled = True
End If
End If


Note: replace cboCaseType with the name of your combo
- replace SubformControlName with your subform control, note that the name
of the subform might be different from the name of the subform control.
- replace 'Partners' with your name for this field/control
-replace [NameOfNameField] with your name for this field/control.

When you say "Parent Form's field "Name".
If you do have a field called "Name", it is best to change it to something
like FirstName or LastName.
Reason: "Name" is a reserved word in Access, in other the work 'name' means
something different inside the workings of access.
If you use this for a field or control name, access will get confused and
you will get an error in your code.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top