Results 1 to 5 of 5
  1. #1
    cmray58 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    5

    Make field in a form active or inactive based on the value of a calculated field

    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).

  2. #2
    dashiellx's Avatar
    dashiellx is offline Falconer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Baltimore
    Posts
    49
    It seems to me that the Current event is where you want to place this code. Then in the after update even any control on the form where the calculation would be updated you need to requery the form so the current event fires again, or just update the calculated control.

    HTH.

  3. #3
    cmray58 is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    5
    Quote Originally Posted by dashiellx View Post
    requery the form so the current event fires again, or just update the calculated control.
    I'm trying to avoid putting the code into every single control on the form. What would I use to "requery the form" and what do you mean update the calculated control? The control seems to be updating on it's own. Meaning, when the calculated value changes, the recalculated value does​ show up in the text box.

  4. #4
    dashiellx's Avatar
    dashiellx is offline Falconer
    Windows 10 Access 2016
    Join Date
    Jan 2019
    Location
    Baltimore
    Posts
    49
    Quote Originally Posted by cmray58 View Post
    I'm trying to avoid putting the code into every single control on the form.
    Yep. That's what I do as well. Sometimes it is unavoidable. But your are correct, if you can avoid it, do so.
    Quote Originally Posted by cmray58 View Post
    What would I use to "requery the form" and what do you mean update the calculated control? The control seems to be updating on it's own. Meaning, when the calculated value changes, the recalculated value does​ show up in the text box.
    The only code you need should be : Me.Requery If you put this on the after update event of every control, it should refire your form's current event and set the active/inactive control you are trying to calculate.

    HTH

  5. #5
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Cross posted at https://www.access-programmers.co.uk...=1#post1611118 also with answers
    Standard crossposting link given at the other site
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 5
    Last Post: 11-03-2017, 06:48 PM
  2. Replies: 1
    Last Post: 05-22-2017, 05:59 AM
  3. Replies: 5
    Last Post: 12-07-2016, 09:28 PM
  4. Replies: 1
    Last Post: 12-04-2016, 05:43 PM
  5. Replies: 1
    Last Post: 02-03-2016, 05:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums