With the code you posted, if Combo50 is anything other than 4, the enabled
property of MonthlyRent and WeeklyRent will remain as they were. You need
the option of setting Enabled to True for MonthlyRent and False for
WeeklyRent. You could do:
Me.MonthlyRent.Enabled = (Me.Combo50 <> 4)
Me.WeeklyRent.Enabled = Not Me.MonthlyRent.Enabled
Or you can turn it around:
Me.WeeklyRent.Enabled = (Me.Combo50 = 4)
Me.MonthlyRent.Enabled = Not Me.WeeklyRent.Enabled
Or use a Boolean (Yes/No) variable:
Dim blnRent as Boolean
blnRent = (Me.Combo50 = 4)
Me.MonthlyRent.Enabled = Not blnRent
Me.WeeklyRent.Enabled = blnRent
The point is that there are a number of ways to approach it, but using Not
helps eliminate some lines of code. In the first example, this expression is
either True or False:
(Me.Combo50 <> 4)
If Combo 50 = 4, (Me.Combo50 <> 4) is False, so the first line becomes:
Me.MonthlyRent.Enabled = False
The next line sets WeeklyRent.Enabled to the opposite of MonthlyRent.Enabled.
The other code does the same thing, but with different syntax that may work
better in some situations. Using the variable (the third example) can be
especially helpful if there are a number of controls that need to be enabled
or disabled.
Whatever you choose, you will probably want the same code in the form's
Current event.
As a suggestion, you will be doing yourself a favor if you give combo boxes
and other controls names that have some meaning, and are different from the
field names. If the field is named MonthlyRent, the text box could be
txtMonthlyRent. The combo box could be something such as cboRentPeriod.
ok here goes, i fiddled a bit and changed it
If Me.Combo50.Value = 4 Then
Me.MonthlyRent.Enabled = False
Else
Me.WeeklyRent.Enabled = True
End If
this works except for a couple of things
when anything other than 4 is selected then i need to disable WeeklyRent
instead
how do i create multiple criteria?
also, if you inadvertantly select the wrong code you have to close the form
and reopen it - is there a way around that?
Why not make today the day you write your first code? All Access
programmers eventually have to.
[quoted text clipped - 19 lines]
so if they select option 1 then box 2 is unavailable and vice versa
.
--
Message posted via AccessMonster.com
.