Solved

OptionButn group=>(single value in DB)

Posted on 1998-07-01
3
128 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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