Full Version: Option Button
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
mac_baum
There seems to be two types of Option Buttons in a form - one within an acOptionGroup another stand alone. The one in the acOptionGroup has no Validation Text while the other does.

Here is the situation. I have an extractiion engine that automatically extracts the Validation Text from objects in a selected form. When the engine attempts to extract Validation Text from the Option Button within an acOptionGroup, I of course get an error.

Is there any way of distinguishing between the two?

Thanks
Doug Steele
Check the name of the Parent of the control. It'll either be the name of the form (for stand-alone) or the name of an option group.

CODE
Dim ctlCurr As Control
Dim strMessage As String
  
  For Each ctlCurr In Me.Controls
    If ctlCurr.ControlType = acOptionButton Then
      If ctlCurr.Parent.Name = Me.Name Then
        strMessage = strMessage & ctlCurr.Name & " is stand-alone." & vbCrLf
      Else
        strMessage = strMessage & ctlCurr.Name & " is in control group " & ctlCurr.Parent.Name & vbCrLf
      End If
    End If
  Next ctlCurr
  
  If Len(strMessage) > 0 Then
    MsgBox strMessage
  Else
    MsgBox "No option buttons found on the form"
  End If
mac_baum
Thanks for the solution. Works like a charm.
mac_baum
djsteele,

Sorry but I was a bit too hasty in my accepting the solution. On further testing I found that suggestion did not work. Your code is fine. I tested it as is in another form.

The extraction engine runs in a module called from another form. The code looks like this

For Each ActiveObject in ActiveForm

Select Case ActiveObject.ControlType
.
.
.
Case acOptionButton
Extract "StatusBarText"
Extract "ValidationText"
.
.
.
End Select

All other extractions work fine except the OptionButton which gives a run-time error 2455.

I tried trapping for that error. It traps on the first occurence of this error but not the next.

Any ideas?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.