Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    52

    Unanswered: How to check if a radiobutton has been selected in a frame?

    Hi,

    I have a frame (frame1) with 3 radiobuttons in it,
    opt1
    opt2
    opt3

    The frame defaults to 'none selected'. I want to make sure the user selects an option, therefor, I use this if-clause:

    if (me.opt1.value=0) and (me.opt2.value=0) and (me.opt3.value=0) then
    msgbox ("No option selected")
    endif

    Alas, this results in the error 'You entered an expression that has no value'

    How do I need to check if a button has been chosen?

    PS: AC97

  2. #2
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: How to check if a radiobutton has been selected in a frame?

    Originally posted by ptrapp
    Hi,

    I have a frame (frame1) with 3 radiobuttons in it,
    opt1
    opt2
    opt3

    The frame defaults to 'none selected'. I want to make sure the user selects an option, therefor, I use this if-clause:

    if (me.opt1.value=0) and (me.opt2.value=0) and (me.opt3.value=0) then
    msgbox ("No option selected")
    endif

    Alas, this results in the error 'You entered an expression that has no value'

    How do I need to check if a button has been chosen?

    PS: AC97
    You have to check the Frame's Value ... When a radiobutton is part of an option group it's Value property is not set. The option groups's is ...

  3. #3
    Join Date
    Mar 2004
    Posts
    52
    If I try:

    If Me.frame1.value= Null then
    Msgbox("Select an option")
    else
    Msgbox(me.frame1.value)
    endif

    ...it gives me the error (at the second msgbox, the else clause)
    Invalid use of null. However, in the first if i checked for null!

    The same goes if I change the 'null' in the if to -1.

    PS: the value for the frame is read 'on load' from a database field, a field which is empty.

    I hope you can help...

  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    If IsNull(Frame1) Then
    MsgBox ("Enter ...")
    Else
    MsgBox (Frame1)
    End If
    End Sub

  5. #5
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by ptrapp
    If I try:

    If Me.frame1.value= Null then
    Msgbox("Select an option")
    else
    Msgbox(me.frame1.value)
    endif

    ...it gives me the error (at the second msgbox, the else clause)
    Invalid use of null. However, in the first if i checked for null!

    The same goes if I change the 'null' in the if to -1.

    PS: the value for the frame is read 'on load' from a database field, a field which is empty.

    I hope you can help...
    Your error is in how you test for nullness ... Change the conditional to:

    If isnull(frame1.value) then

    Question: Why don't you set the default option of the option group? Something to consider: Every radiobutton is assigned an option value defaulting at 1 and increasing from there (it is overrideable) so having no default selection on startup you could use 0 ...

  6. #6
    Join Date
    Mar 2004
    Posts
    52

    Talking

    Thank you guys !!!!!

Posting Permissions

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