Solved

OptionButn group=>(single value in DB)

Posted on 1998-07-01
3
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 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