Vary sub form labels depending on other value

Gavx

Registered User.
Local time
Tomorrow, 01:38
Joined
Mar 8, 2014
Messages
155
I have a form containing a sub form.

On the sub form I am selecting products that I am selling to a customer whose details appear on the main form.

The products on the sub form are selected from a combo box. This section is in datasheet format.

Depending on the product sold some of the labels on the sub form are not relevant. And when this is the case I was thinking maybe the label is rendered invisible.
Maybe this is not the best way to handle this - or is it. It certainly is expedient.

Perhaps as well when the label is rendered invisible entry of a value into the corresponding text box becomes impossible.

Is there a better way to handle this?

Alternatively can anyone suggest how I can render the label invisible and disallow data entry depending on the value of the combo box.

thanks
 
One way to handle this is in the subform current event.

The code would be something like

myLabel.visible=myComboBox="Some Condition"
myControl.enabled=myComboBox="Some Condition"
 
Further to the good advise from Chris, you may need similar code in the After Update event of the combo box
 
Thanks, that looks like it will work but I am having trouble referring to the value of the combo box.

This is my statement

txtDateOut.Enabled = cbProductName = "Arrival Flight"

Am I referring to the value Arrival Flight correctly?

I have confirmed;

txtDateOut is correct
cbProductName is correct and that the contents of this field is Arrival Flight.

So I would expect that if the combo box reads Arrival Flight then the control txtDateOut should be enabled...but it isn't.
 
what is the rowsource for cbProductName? "Arrival Flight" needs to be in the bound column

If Arrival Flight is not in the bound column then your code needs to be

txtDateOut.Enabled = cbProductName.column(x) = "Arrival Flight"

where x is the column number
 
Thanks.

I am now getting an error message "Invalid use of Null" when I start entering on the main form.

Is an error handler such as On error resume next the correct treatment?

Or should there be some sort of statement about if null then...
 
you can try

txtDateOut.Enabled = nz(cbProductName.column(x),"") = "Arrival Flight"
 

Users who are viewing this thread

Back
Top Bottom