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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Groups Help

Status
Not open for further replies.

Geodon7

Technical User
Jun 24, 2002
27
0
0
US
I've posted questions about this before, and I'm making progress but I still can't get it to work the way I need it to.

So I have an option group with three options: contract, project request, other. Next to the contract and project request options there are dropdown boxes. The dropdown boxes are populated from other tables with the different projects that exist. The other option has a textbox next to it to be filled in.

The way it is now, I have it so that if you choose one of the options, say contract, then the dropdown box next to contract is the only one that is enabled. And if you switch your choice, the choice you switch to has the only available box next to it.

The next step is what I need help with. If you have chosen contract and make a choice in the dropdown box, then change to project request I have finally figured out how to reset the first box so that nothing is entered there or into the table. However, when you click in the enabled dropdown box, the choice in the option group resets to the default value.

I’m not too experienced in VBA, but I’ll post the code I have below. Any suggestions on how to improve what I’m doing and to make it so that the option group value isn’t reset to the default value? Thanks in advance.

Code:
Private Sub Option36_GotFocus()
    [Other].Enabled = False
    [ContractDrop].Enabled = True
    [ProjectDrop].Enabled = False
    [Other].Undo
    [ProjectDrop].Undo
End Sub

Private Sub Option36_LostFocus()
    Me.Undo
End Sub

Private Sub Option38_GotFocus()
    [Other].Enabled = False
    [ContractDrop].Enabled = False
    [ProjectDrop].Enabled = True
    [Other].Undo
    
End Sub

Private Sub Option38_LostFocus()
    Me.Undo
End Sub

Private Sub Option40_GotFocus()
    [Other].Enabled = True
    [ProjectDrop].Enabled = False
    [ContractDrop].Enabled = False
    
    [ProjectDrop].Undo
End Sub

Private Sub Option40_LostFocus()
    Me.Undo
End Sub

Thanks again
G
 
The code is a little messy here, (please don't be offended).
What you seem to be doing is using individual option buttons, then trying to create the required 'option group' behaviour. If you drop a frame onto your form, then drop the required option buttons inside it, you will automatically have created an option group. Each option button will have an option value, and you can use these in your code, for example:

Select case MyOptionGroup (this will be the name of the frame)

Case 1
[Other].Enabled = True
[ProjectDrop].Enabled = False
[ContractDrop].Enabled = False
Case 2

......

End Select

If you use this method you should find the problems with the values of the option buttons disappears.

Hope this helps

Clare
 
Thank you for your help, I just have some questions. I'm pretty new at all of this, so I was basically just using the wizards. So I drop an object frame (unbound or bound?), then I put the option buttons inside. I tried this, first with a bound frame, then with an unbound frame, but both times I received an error saying that "the operation on the OLE failed. The OLE server may not be registered. To register the OLE server, reinstall it."

Any suggestions with this one? I'm using Access 2000, but I don't know if I have the software because it was installed before I started working here. Is there any way around this other than contacting IT and trying to get that reinstalled?

Thanks for all your help!
Geoff
 
Sorry Geoff, I may have misdirected you a little there when I referred to a frame. Its the object in the toolbox with the 'XYZ' at the top, it is actually called 'Option Group'.
Access labels it as a 'Frame' once its dropped onto the form.

apologies

Clare
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top