Disable Control Based on Linked Subform

G

Guest

My main form contains info on products. I have a subform on the main form
called suppliers. When this subform is empty (contains no records), I want to
be able to disable a control called “manage†on the main form. I’ve tried
everything and can’t seem to get the syntax correct or I am putting the code
in the wrong event property.

1) Should the code be put on the main form, the subform, or the control on
the main form that I want to disable? Secondly, where should the code go? On
current? Before update? etc.

2) What should the code look like? Following is an example that I can’t get
to work that was placed on the On Current event in the main form.

If Forms!ChemicalInventory.EditSuppliers.SupplierName = IsNull Then
Me.Manage.Enabled = False
End If

I get errors saying the argument ISNull is not optional. Any help would be
appreciated. Thanks.
 
G

Guest

The reason for the error is that IsNull is a function which expects an
argument, e.g.

If IsNull(Me.EditSuppliers.SupplierName) Then

but a I'd suggest simply counting the subform's records like so:

Me.Manage.Enabled = (Me.EditSuppliers.Form.RecordsetClone.RecordCount > 0)

Note that EditSuppliers here is the name of the subform <control> i.e. the
control in the main parent form which houses the subform, not the name of its
underlying form object, though both can have the same name.
 
G

Guest

Thanks a million Ken! I am always hesitant to use the newsgroup until I spend
a few hours trying to figure it out myself. Thanks to you and the group!
 

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