Checking if Option Group empty

  • Thread starter Thread starter Dinsdale
  • Start date Start date
D

Dinsdale

Team,

Got a form with an option group of 4 buttons. The user can complete the
form without completing the option group and I am hoping to get some
code which will check the fact that none of the option buttons are
checked and provide a message box (which is no problem). Tried an isnull
property with no success. Any ideas?

TIA,

Andrew
 
I just checked, it appears that the value of the frame is Null if none of
the options are selected. This will change though if you have a default
value set in the table, even if it's not set in the control, and that
default value is not a value selectable by the option buttons.
 
Wayne,

Yes, I thought that, but if I do something like the following nothing
happens.

if me.training_education_categories = Null then
msgbox
end if

Where training_education_categories is the name of the option group. I
have no default values set.

Andrew
 
Andrew,

Put this code immediately before you If statement. It will tell you the value of
the option group when nothing is checked:

MsgBox Me!training_education_categories

You can then use that value in your If statement and delete the temp code.

Another point - the correct way to check if a control is null is like this:

If IsNull(Me!training_education_categories) Then
 
Dinsdale said:
Wayne,

Yes, I thought that, but if I do something like the following nothing
happens.

if me.training_education_categories = Null then

Nothing is ever "equal" to Null. In VBA you need to use the IsNull() function
and in a query you use the Is Null clause.
 
You could set the default value of the frame to be something other than the
option values and null if this is causing you problems - you could set it to
be 100 for arguments sake. Then include this number in the check.

Select Case Me.MyFrame
Case 1
Case 2
' e.t.c.
Case 100
' Default value - no option has been selected
End Select

HTH,

Neil.
 
Thanks.

Andrew

PC said:
Andrew,

Put this code immediately before you If statement. It will tell you the value of
the option group when nothing is checked:

MsgBox Me!training_education_categories

You can then use that value in your If statement and delete the temp code.

Another point - the correct way to check if a control is null is like this:

If IsNull(Me!training_education_categories) Then


--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com
 
Rick,

I saw the hint for making the option group equal to Null elsewhere, but
realise now that this is the means for turning any values within the
group off.

Thanks

Andrew
 
Thanks Neil.
You could set the default value of the frame to be something other than the
option values and null if this is causing you problems - you could set it to
be 100 for arguments sake. Then include this number in the check.

Select Case Me.MyFrame
Case 1
Case 2
' e.t.c.
Case 100
' Default value - no option has been selected
End Select

HTH,

Neil.
 
Dinsdale said:
Rick,

I saw the hint for making the option group equal to Null elsewhere, but
realise now that this is the means for turning any values within the
group off.

Correct. You can use = to *assign* something to a Null value, but not to test
for it.
 
Back
Top