G'day,
I am working on a database in which I will the user will be inputting the dimensions of something. Some of these are round, other are rectangular. What I'm trying to do is either enable/disable or hide the diameter field for rectangular parts, and visa versa.
In the On_Current event of the form I've been able to get the following to work:
Code:
Private Sub Form_Current()
If Me.Style = "Disc" Then
Me.MaxDiameter.Enabled = True
Me.MaxLength.Enabled = False
Me.MaxWidth.Enabled = False
ElseIf Me.Style = "Rectangular" Then
Me.MaxDiameter.Enabled = False
Me.MaxLength.Enabled = True
Me.MaxWidth.Enabled = True
End If
End Sub
However, the problems start when trying to utilize the same "Style" condition in my subform. When I try to add something like the following, I get an error saying that I can't disable a control while it has focus:
Code:
Private Sub Form_Current()
If Me.Style = "Disc" Then
Me.MaxDiameter.Enabled = True
Me.MaxLength.Enabled = False
Me.MaxWidth.Enabled = False
Me!sfrmRecipe.Form.DiameterPre.Enabled = True
Me!sfrmRecipe.Form.LengthPre.Enabled = False
Me!sfrmRecipe.Form.WidthPre.Enabled = False
ElseIf Me.Style = "Rectangular" Then
Me.MaxDiameter.Enabled = False
Me.MaxLength.Enabled = True
Me.MaxWidth.Enabled = True
Me!sfrmRecipe.Form.DiameterPre.Enabled = False
Me!sfrmRecipe.Form.LengthPre.Enabled = True
Me!sfrmRecipe.Form.WidthPre.Enabled = True
End If
End Sub
Any suggestion on how to either make this work or go about it a different way? If I could get it to hide the fields I think it will work best. Disabling them was just where I started the tinkering.
Thanks!
Scott