Make field in a form active or inactive based on the value of a calculated field (1 Viewer)

cmray58

Registered User.
Local time
Today, 12:35
Joined
Mar 24, 2014
Messages
70
I have a query that is calculating a client's eligibility for services. This field's output is either Yes or No depending on data from a series of other fields (automatically calculated).

On my form, I would like the "Interested" field to be active only when Eligibility is Yes. Something around these lines:

Code:
If [Eligible_PROSPollock] = "Yes" Then
Interested_PROSPollock.Enabled = True
Else
Interested_PROSPollock.Enabled = False
End If

I've tried putting this code in a few different event options, but I cannot get the field to dynamically switch from active to inactive or vice versa without manually clicking Refresh. I'd like the field to automatically activate or deactivate each time the Eligibility field changes from Yes to No or vice versa. Reminder, the Eligibility field is never changed by the user manually, it is also an automatically calculated field (iif statement from the source query).
 

isladogs

MVP / VIP
Local time
Today, 20:35
Joined
Jan 14, 2017
Messages
18,209
Try the Form_Current event

It shouldn't be necessary, but if still not updating add the line Me.Requery after your code

One other thing.
If the Eligible_PROSPollock field is Yes/No then replace the first line with
Code:
If Eligible_PROSPollock=True Then
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 15:35
Joined
May 21, 2018
Messages
8,525
I am going to assume that this really is a text field "Yes" vs TRUE. I would write the procedure once and call it several times

call it from the forms on current and any fields afterupdate that impacts the calculated value.

Code:
Private Sub ChangeProsPollock()
   'slightly modified
   me.Interested_PROSPollock.Enabled = (Me.Eligible_PROSPollock = "Yes")
end sub
 

Micron

AWF VIP
Local time
Today, 15:35
Joined
Oct 20, 2018
Messages
3,478
Reads like you need to use the AfterUpdate event of the checkbox to do the enabling/disabling. Clicking refresh is a manual way to cause form controls to be recalculated, so you could also just Me.Refresh somewhere.
 

Users who are viewing this thread

Top Bottom