How to turn on/off AllowAddition using command button?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,

How may I turn on/off AllowAddition property of a query in a subform using
command button?

Regards,
Sam
 
In the Click event of the button (assuming the button is on your main form
and not the subform) use this

Me.SubFormName.Form.AllowAdditions = True
or set to False to switch off
 
Thanks Dennis, works beautifully :)
Other than just turning on the subform's AllowAdditions, I also would like
to unlocked the controls and change their forecolor in the subform, using the
same command button. But the lines I tried below seem wrong as an error
message says "Method of data member not found". What would be the correct way
of doing it then? The defalut view of the subform is Datasheet.

Private Sub cbEditAmendment_Click()
' Turn on the subform's AllowAdditions property
Me.NameOfSubform.Form.AllowAdditions = True
' Unlock all controls in the subform
Me.NameOfSubform.FormerDWGNo.Locked = False
' ("FormerDWGNo" is hightlighted as error)
Me.NameOfSubform.FormerDWGNo.ForeColor = 225
End Sub

Regards,
Sam
 
Yes! Cheers, Dennis.

But ForeColor would not change if the subform is in Datasheet view (I tried
having it to Single Form instead, then forecolor changes). Does that mean I
cannot change the fore color of subform's controls, if I really want to have
the subform in Datasheet view?

Regards,
Sam
 
Back
Top