Results 1 to 4 of 4
  1. #1
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118

    Option Group Event problem

    I have an option group on a form labelled Approved (value 1) and Declined (value 2) the values go into a text box “Approved_Declined” where the visible properties are false.
    If the user selects Approved option I want to enter current date into “Date_Approved_Declined” & clear ant data from “DeclinedReason”
    If the user selects Declined option I want to make the “DeclinedReason” field visible & enter current date in the “Date_Approved_Declined”


    I have used the following code on the ‘On Change’ property of “Approved_Declined” field. But nothing works when selecting the option buttons. If I manually change the “Aproved_Declined” (this will not be visible in the final desighn) field my MsgBox Test works but not the current date update. Am I using the wrong property to attach the code to, but if so where should I put it? Thanks
    'MsgBox "test"


    Date_Approved_Declined = Now()
    If Approved_Decline = 2 Then
    Me.DeclineReason.Visible = True
    Else
    Me.DeclineReason.Value = ""
    Me.DeclineReason.Visible = False
    End If

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    help if you used the correct terminology - fields do not have events, controls and form object components do.

    But sounds to me like you need to be using an event (suggest afterupdate) on your Approved option group control since it would appear this is where you want to be triggering the code.

    The change event is only valid whilst the control has the focus and does not impact the final value of the control until it is updated/lost focus. So you might use it in a control where the user is typing and you want to do something every time they enter or remove a character. Note that pasting a value into a control will also trigger the change event since it has to receive the focus to accept the paste. However modifying the control value by using vba or a macro will not trigger the change event since it does not receive the focus.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Try the AfterUpdate event of Option Group frame control.

    Set radio button values to 0 (False) for Declined (i.e. NotApproved) and -1 (True) for Approved then code:
    Code:
    With Me
    If .Option Then .DeclineReason = Null
    .Date_Approved_Declined = Now()
    .DeclineReason.Visible = Not .Option
    End With
    I don't allow empty string in fields so I use Null instead of "".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Ant_Snell is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jul 2021
    Location
    UK
    Posts
    118
    Thanks June7, that's sorted it. Easy when you know what you are doing!

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

Similar Threads

  1. Replies: 7
    Last Post: 12-27-2021, 10:20 AM
  2. Option Group Control: Cancel click / update event
    By ironfelix717 in forum Programming
    Replies: 7
    Last Post: 04-26-2021, 02:30 AM
  3. Replies: 14
    Last Post: 06-25-2020, 08:42 AM
  4. I have a problem with option group's code.
    By llgtjb001 in forum Programming
    Replies: 11
    Last Post: 09-25-2015, 02:06 PM
  5. Dependent option group problem
    By Remster in forum Programming
    Replies: 5
    Last Post: 10-22-2010, 10:23 AM

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