Automaticaly fill in a field based on another filed.

AndrewG

New member
Local time
Today, 03:35
Joined
Jun 18, 2003
Messages
5
Can anyone tell me if I can do this? Let's say I have a form with two fields: score and grade. I want to fill in the grade field based on data in the score field, for example if I enter a value between 90 and 100 in the score field, "A" would automatically be entered in the grade field. If I enter a value between 80 and 89 in the score field, "B" would automatically be entered in the grade field etc. Thanks for any advice.
 
Use a function like this as the controlsource of the textbox where you want to calculate the letter grade.

Function GetLetterGrade(intScore As Integer) As String
  Select Case intScore
    Case Is > 90
      GetLetterGrade = "A"
    Case Is > 80
      GetLetterGrade = "B"
    Case Is > 70
      GetLetterGrade = "C"
  End Select
End Function


In the controlsource for the textbox, enter this: =GetLetterGrade([txtscore]) where score is the name of the text box where you typed in the numeric score.
 
Last edited:
to DCX693 Your Previous Reply

Thank you for your previous reply. I made the query as you instructed. May I ask you to explicate a little on the last paragraph of your solution?

"To use this query in your form, place a reference to the form filed inthe criteria line for the StudentID, and bind the third column of the query to the combo box."

Alas, I am not yet an advanced Access user.
 

Users who are viewing this thread

Back
Top Bottom