Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access Option Buttons 1

Status
Not open for further replies.

akins4lyfe

Programmer
Oct 6, 2010
39
GB
Hi,

I have a form containing 5 option buttons, to check for series of specific validities, 1 command button, and a text box to display validity notes.

I would like a user to select an option by checking the option buttons, then click on the command button, and place a note inside the text box available on my form. An option must to be selected, it's compulsory.

Depending on the option selected by the user, there are different notes available for each options.

Now, here is the problem, the first option works fine, when selected, and the command button clicked to generate a note. But the rest are not working. I have posted my code below, for any suggestions, critics & corrections pls.

If Me.OptionValid90.Value = True Then
Me.txtNote "Welcome on board"
ElseIf Me.OptionValid28.Value = True Then
Me.txtNote = "Valid for 28 days only"
ElseIf Me.OptionInvalid.Value = True Then
Me.txtNote = "Your subscription is Invalid"
ElseIf Me.OptionInvalidV6.Value = True Then
Me.txtNote = "V6 Validity"
ElseIf Me.OptionManagerAuth.Value = True Then
Me.txtNote = "Authorisation Required"
Else
Me.txtNote = ""


Thank you all.
:)
 
Normally you return the value of the option group not the individual controls in the group

private sub mygrp_afterupdate()
select case myGrp
case 1
'do something if first option choose
case 2
'do something if second option choose
case N
end select
end sub
 
Thanks Majp, i thought about Using a Case as well, but my project involved selecting not more than one option at a time.

Although, strange enough, i have now resolved this issue, by twitching around my code a bit.

This was how i did it,

Validating each options in the group, so that when an option is selected, then the rest of the options are Unselected, or disabled. That way, the required note, assigned to that option could be generated

Also i corrected line 2 of my code, assignment operator seems missing.

Me.txtNote "Welcome on board"

Corrected to:

Me.txtNote.Value = "Welcome on board"

Thanks a lot, for your input.
 
How are ya akins4lyfe . . .

I've kept my eye on this thread always wondering if you truly had an [blue]Option Group[/blue] or just [blue]five independent option buttons[/blue]. I suspected independent buttons because you went to the trouble to give them names. As it turns out (via your last post), its independent buttons. I didn't want you leaving without understanding the difference.

[blue]MajP[/blue] was refering to an actual [blue]Access Option Group[/blue] ... there's even a wizard for it. If you had read the link provided by [blue]MajP[/blue], you would've seen that an option group [blue]only allows a single selection[/blue]. And that these selections are indexed (hence [blue]MajP's[/blue] select case statement).

If you had used the [blue]Option Group Wizard[/blue] you could've saved yourself deselecting the other buttons when one is selected ... this would be done automatically.

So take a break and really read [blue]MajP's[/blue] link and be done with [blue]Option Group[/blue] once and for all.

[blue]Your Thoughts? . . .[/blue]



See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hi TheAceMan1,

Thanks for adding your thoughts, regarding this issue.

You are correct, i initially had series of independent option buttons placed on my form, as specified within my first post. I chose to use each options independently because of the nature/specific requirements of my project.

The Majp link was also helpful, as i eventually used an option Group wizard, therefore commenting out validations for each option buttons.

Also, i have now saved Majp link for future references.

Thank you all.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top