Either Or, If one is chosen Dim the other & Vice Versa

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

I have two controls on my form and if the user chooses one, I want the other
to dim so they cant use both, only one.
The two controls are named FlatDisc and Disc
The form name is TimeCards
FlatDisc is in currency format and default value is 0
Disc is a number with a fixed format, i.e. .10 as in 10%

How can I do this?
 
Assuming that "select one" means that the user is changing the value of the
control, use the AfterUpdate event of each control to disable the other
control:

Private Sub FlatDisc_AfterUpdate()
Me.Disc.Enabled = False
End Sub


Private Sub Disc_AfterUpdate()
Me.FlatDisc.Enabled = False
End Sub
 
Yes, that is true, however if the control Disc has a default value of 0
and the user changes to 1 then the control FlatDisc will be disabled
There is no way to enable the FlatDisc control again if the value of Disc
is Zero
So if the value of Disc for the current record is Zero and you change it
then the control FlatDisc will disable, else if it is Zero (Disc) the
control is enabled (FlatDisc).
Need the control Disc on the update event to disable the control FlatDisc
if the value is greater that zero for Disc
Same is true for FlatDisc, if the value is greater that zero, then Disc is
disabled else Disc is enabled.
Cant have both, just one and if one changes and is greater than zero the
other control is disabled.
It will stay disabled for all records which is not what (Just the Current
Record)
 
I definitely am not sure that I am following this... as I read your post,
you say you want to disable FlatDisc but you want to be able to reenable
it -- but it's not all clear how the "toggling" is to work. Once you disable
the control, when does it supposedly need to become reenabled?

Perhaps use code similar to this on the Current event of the form, in
addition to the modifying the code I'd posted earlier?

Private Sub Form_Current()
Me.FlatDisc.Enabled = (Me.Disc.Value = 0)
End Sub


Private Sub FlatDisc_AfterUpdate()
Me.Disc.Enabled = (Me.FlatDisc.Value = 0)
End Sub


Private Sub Disc_AfterUpdate()
Me.FlatDisc.Enabled = (Me.Disc.Value = 0)
End Sub

--

Ken Snell
<MS ACCESS MVP>
 
The following works just fine, maybe a better way, but it works.
Thanks

If ([Disc]) > 0 Then ' On the update event of the control Disc
Me.FlatDisc.Enabled = False
Else:
Me.FlatDisc.Enabled = True
End If

If ([FlatDisc]) > 0 Then ' On the update event of the control FlatDisc
Me.Disc.Enabled = False
Else:
Me.Disc.Enabled = True
End If
 
Back
Top