automated fields

agorman

Registered User.
Local time
Today, 15:36
Joined
Dec 30, 2006
Messages
68
Hi.

I have a form with 2 fields - one called 'Grade' and the other called 'Type'. Each field has pre-determined entries (20 of them) as in the example below.
Grade: Type:
1 = full
2 = Partial
3 = Semi
4 = Westward
etc etc..

Is it possible for me to enter a grade, for example, '1' in the grade field , and have the 'type' field automatically show 'full' so that I only need to physically enter the 'grade'


Hope that makes sense.

Thanks

Adrian
 
Code:
Private Sub Grade_AfterUpdate()
 Select Case Grade
  Case 1
   Me.Type = "Full"
  Case 2
   Me.Type = "Partial"
  Case 3
   Me.Type = "Semi"
  Case Else
   Me.Type = Null
 End Select
End Sub

Two things:

If your Grade field is text rather than numeric, change your Case statements to reflect this; change

Case 1

to

Case "1"

Secondly, if your Type field is being stored in your table, you're set. If it's not being stored, you'll need to add the same code to your Form_Current event, so that the Type will be re-calculated when you return to a record.

Also note that Type is a Reserved Word in Access. You really should modify the name (like GType or GradeType) or you'll apt to have problems with it down the road.
 
Brilliant ! - works great. Changed the field to gradetype as advised.

Thankyou for that.
 

Users who are viewing this thread

Back
Top Bottom