Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Determine which value is selected in an Excel form option group

I have a form that dynamically presents the user with the required fields to be filled in on an Excel form.  When the user saves the data, I first need to validate that the required fields are populated.  First the user selects on of the options from an option group, this determines what fields are visiable.  So, how do I deterine which option was selected in the group so I can check the data controls?  I don't think what I have is the right direction (and it does not work!)
Private Sub btnSave_Click()
Dim intValue As Integer
intValue = Me.fraPortfolioGroup
Select Case intValue
    Case Me.optActivePortfolios
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Or IsNull(Me.txtURLSectorDetail) Or _
            IsNull(Me.txtURLRatingSummary) Or IsNull(Me.txtURLRatingDetail) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optActiveMiscel
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Or IsNull(Me.txtURLSectorDetail) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optActivePortMastStats
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optIndexPortfolios
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Or IsNull(Me.txtURLSectorDetail) Or _
            IsNull(Me.txtURLRatingSummary) Or IsNull(Me.txtURLRatingDetail) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optIndexMiscel
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Or IsNull(Me.txtURLSectorDetail) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optIndexSFPortfolios
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Or IsNull(Me.txtURLSectorDetail) Then
            Call NullAddProfileMessage
                Exit Sub
    Case Me.optIndexPortMasterStats
        If IsNull(Me.txtPortfolioCode) Or IsNull(Me.txtPortfolioName) Or _
            IsNull(Me.txtURLSectorSummary) Then
            Call NullAddProfileMessage
                Exit Sub
End Select

End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Cory Vandenberg
Cory Vandenberg
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

If I get rid of the intValue and change the IsNull to ="", your code works.  But I will also take a look at the link you provided, thank you!