Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    228

    Question Unanswered: how to cancel click to an option button (problem solved but I'd like an easier way)

    1st off I am a nube so please don't kill me...

    I have an option group with 2 options (accept or reject). If someone tries select an option while the text box above it is empty, I want to put up a message box and then ignore the click. I thought I could do this by adding Cancel As Integer as a parameter to the On_Click event and setting it to true if the text box is null. Everytime I add the parameter the database goes crazy!

    Any advice?

    I have the message box popping up but the option button is still getting selected even though I set Cancel = True in the before_update event if the box is empty...

    Please help
    Last edited by ottomatic; 09-05-03 at 19:36.

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: Difficulty adding "Cancel As Integer" to an event

    You can't change the number or type of parameters of an event. What you should do, is to implement the OnClick event, and checking your condition (textbox = vbNullString and YourOptionArray(Index) = TRUE, for example). In this case, you may come up with your message box, and you can let the other option to be true, making your current option automatically false.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

  3. #3
    Join Date
    Sep 2003
    Posts
    228

    Re: Difficulty adding "Cancel As Integer" to an event

    Originally posted by DoktorBlue
    You can't change the number or type of parameters of an event. What you should do, is to implement the OnClick event, and checking your condition (textbox = vbNullString and YourOptionArray(Index) = TRUE, for example). In this case, you may come up with your message box, and you can let the other option to be true, making your current option automatically false.
    My problem is I start out with a grayed out option group (default state). Let's say the user trys to accept an empty field. They click the Accpet option. My message box comes up and says you can't do that but the Accept button still fills in ... I'm confused as to what you reccommended.

    I finally got it to do what I wanted but it seems like I took the long way.

    I added a mouse_down event for each option button in the control. If the field is empty, I lock the option control and give my error message. This way when the mouse button is released, the field is locked and the option cannot be selected.
    Last edited by ottomatic; 09-05-03 at 19:32.

Posting Permissions

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