Results 1 to 5 of 5

Thread: Simplified IF statements

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2002
    Location
    UK
    Posts
    130

    Simplified IF statements

    OK, basically I have about 24 option buttons on my form. 4 of them per frame totalling 6 frames. When they click a button I want it to make sure that at least one option button is ticked in each frame, without having to do loads and loads of IF statements to check this. Is there a way to check that one is checked per frame?

    I dont want default value of one of the opt buttons in each frame to be 1 incase a user thinks they ticked it as the form is pretty complex and having boxes ticked when they open it will confuse them.

    If you can help then please do. Just to summarise, I need to make sure at least 1 option button is ticked per frame, hopefully without using too much code.


    Thanks
    PJ

  2. #2
    Hyperactive Member Blinky Bill's Avatar
    Join Date
    Mar 2002
    Location
    Happily munching on the greenery in your garden
    Posts
    349
    Ifs will be necessary, however, you can keep them at a minimum if you use 1 boolean flag for each frame, and set it to true every time the user ticks an option in that frame, and set it to false every time they unclick one. Then you will only need the following style if statement

    VB Code:
    1. If flag1 AND flag2 AND flag3 AND flag4 AND flag5 AND flag6 Then
    2.   Msgbox "Form Filled Correctly"
    3. Else
    4.   Msgbox "Missing data"
    5. End If

    Hope this helps.
    We don't know what's wrong. . . So the best bet might be to remove something surgically.

  3. #3
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    All of this should be done automatically if you've designed your form well.

    One radio button is always checked in each frame. Unless you've coded differently.
    Please rate my post.

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    well.. you could always loop through each frame, like this:

    Dim OptBut As OptionButton

    for each optbut in frame1
    if optbut.value = vbchecked then msgbox "checked in the frame"
    next

    and do that for each frame, and maybe exit sub or some kind of jump if it isn't for the whole frame, and at th end it will be the message that says they al were checked.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5

Posting Permissions

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



Click Here to Expand Forum to Full Width