relationship in form?

ubeyou

New member
Local time
Yesterday, 21:43
Joined
Aug 17, 2008
Messages
8
err actually is like this; i created a table name "performance", inside the table got 4 type of rating, "poor", "average", "good", excellent", then each different rating give different bonuses, like poor give 0%,average give 1%,good give 2% and excellent give 3%.

now i want to create a form that only can edit the bonuses. when i select poor, then it appear 0% and can be edited, when i select good, then it will auto change to 1%, then i may edit it if i want.


So how to create this?
 
Last edited:
We really need to see your table structure. For example, you should have one field in your table to hold these four types of ratings? Is that how you have it set up?

There's almost always alternative methods, but here’s how I’d do it.

In my Table:

I’d have whatever other fields you need for ID, etc., then 2 fields

Field: Rating Datatype: Number Field Size: Integer

Field: Bonus Datatype: Number Field Size: Single Format: Percent


In my Form:

Place an Option Group on the form

Walk thru the Wizard:

For labels, enter, in this order

Poor
Average
Good
Excellent


Select No Default

You’ll see the values for each label

Leave the Default of Option Buttons

Enter Rating as the Option Group Name (This is merely the display name)

Hit Finish

Access will name the Option Group control something like Frame0. With the Option Group frame selected, goto Properties - Other and change the name to RatingFrame (this is the control name.) Now goto the Data tab and in the Control Source Property select the field Rating.

Now place this code in the AfterUpdate event of RatingFrame

Code:
Private Sub RatingFrame_AfterUpdate()
 Select Case RatingFrame
  Case 1
    Me.Bonus = 0
  Case 2
    Me.Bonus = 0.01
  Case 3
    Me.Bonus = 0.02
  Case 4
    Me.Bonus = 0.03
 End Select
End Sub

Go back to form Design View

Select the textbox for holding the bonus percentage (cleverly called in the above code, Bonus!) And goto Properties - Format and in the Format Property select Percent.

Now run the form. As you select a Rating, you should see the Bonus fill in appropriately, but you can manually change the Bonus assigned.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom