Solved

OptionButn group=>(single value in DB)

Posted on 1998-07-01
3
126 Views
Last Modified: 2010-05-03
In Delphi it is possible to use a group of "radio buttons" (option buttons) to represent a single field in a DB.ie each button has an assigned value wich-when selected- is written to the specified field in the DB. Is this possible in VB5? seems to me that with the standard (ActiveX) component suplied with VB each button bust be bound to its own field? I could not find any documentation describing the methodology of binding option buttons to a DB in the manuals. Im using VB5(Enterprise Ed.)
0
Comment
Question by:Deep Diver
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 100 total points
ID: 1464660
Set up your Data Control: DatabaseName and RecordSource
Set up a Label:DataSource, DataField and Visible = False

Use the following code (this could be modified to use a control array of option boxes)

Private Sub Label1_Change()
    Select Case UCase$(Label1.Caption)
    Case "X": Option1.Value = True
    Case "Y": Option2.Value = True
    Case "Z": Option3.Value = True
    End Select
End Sub

Private Sub Option1_Click()
    Label1.Caption = "X"
End Sub

Private Sub Option2_Click()
    Label1.Caption = "Y"
End Sub

Private Sub Option3_Click()
    Label1.Caption = "Z"
End Sub

0
 

Author Comment

by:Deep Diver
ID: 1464661
Hi "swilt"
Thats a very usefull trick. Thanks.
My only problem with this solution is that in my program there is about 50+ instances of this problem (I maybe should have said this in my question...sorry). However if nobody else have any comments/answers that uses less code I will award you the points.

Regards
Riaan
0
 

Author Comment

by:Deep Diver
ID: 1464662
Hi again!
I just tried out the Indexed version of your proposed answer; only 2 instructions!

I now realize that my previous comment was very much uninformed!
Here's your 100 points!

Regards
Riaan
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now