Results 1 to 4 of 4

Thread: Cancel event

  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cancel event

    Cancel event

    I want to cancel the OnClick event if the control is clicked before an option is being made in an option group. The Option group with me is called Office.
    I have tried to build the following code in the OnClick event

  2. #2
    Mike B
    Guest

    Re: Cancel event

    If opt=0 Then
    DoCode
    Else
    If opt=1 Then
    DoCode
    Else
    If opt=2 Then
    DoCode
    Else
    MsgBox "Please make a selection in the option group"
    End If
    End If
    End If

    HTH

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Cancel event

    The problem is that there is no Cancel argument for the OnClick event. Your code should work without the Cancel line as long as everything you would do if a choice had been made is contained within the Else part of your If ... EndIf.

    I would suspect that the problem lies in your comparison "If Forms![Fsurvey]![Office] = False ...." Do you have a default of zero set for the option group? Do all the option values start at above zero? You're testing for a zero value, and if you have a null default, you won't have a zero value unless it belongs to one of the options.
    Charlotte

  4. #4
    dmatherton
    Guest

    Re: Cancel event

    This may be overkill, but...

    Why not set the .enabled property of the control to False in the Form_Open event. You can then put code into the _AfterUpdate event of your option group, to re-enable the control only after a selection has been made.

    D.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •