I have a project dealing with income taxes that has a userform with option buttons. It is set to create a max of 2 records. I am validating the option button selection is correct, i.e. 'Married Filing Jointly' on one record can has to be the same on the other record. There are several other variations of validation. The validation function is ControlValidate
in the userform.
On the Save button click event, I am checking to see which option button is set to True and then run ControlValidate
to do the scenario testing. Here is the code giving me fits.
Dim FilingStatus As String
Dim CheckFor As String
Dim CurrentControl As Control
Dim ValidateTaxFiling As Boolean
CheckFor = FilingStatus
With Me.Controls
ValidateTaxFiling = True
If Me.obHH = True Then
FilingStatus = Me.obHH.Caption
Set CurrentControl = Me.obHH 'option button
CheckFor = CurrentControl.Name
Cancel = Not ControlValidate(CheckFor, CurrentControl, ValidateTaxFiling)
[...a few Elseifs....]
End If
End With
My problem is that the line Set CurrentControl = Me.obHH
returns the boulean value of the Me.obHH
. I need the control name passed to the valdiation function. None of the options I have tried gets me there. Me.obHH.Name
gives me a type mismatch (understandably). Presumable, if I can get the name of the option, I can do thisin a loop instead of nested if/elseifs. Any ideas? I appreciate any help.