Need a field to return a value based on another field value

grenee

Registered User.
Local time
Today, 06:13
Joined
Mar 5, 2012
Messages
212
How can a field be coded in VB to return a valued based on the values in another field.

I need it to occur when the form is loaded and not by trigering an event like DBlclick etc.

This is the code that I used but with no success:


Private Sub Text19_Enter()
If Hours.Value = "" Then
Text19.Value = "Error"
End If
End Sub
 
If you need to have an event occur when the form is loaded, then put your code in the OnLoad event for the Form.

Alan
 
Thanks, but I don't need an event triggered. I just need the value out putted like any other field quiery.
 
What are you trying to test for? Are you trying to make sure that Hours contains some value? If that's the case, depending on your data type, you probably want to test to see if Hours > 0.
 
Thanks Bryan.

Actually the Scores field contains numeric values but also string, namely "A" for absent if a student was absent for the exercise.

What is needed is a comment next to each score stating that a student 'Pass' or 'fail' or was 'Absent' or got a grade 'A' or 'B' or 'c' etc.
 
I think your table should have a field probably populated from a fixed list of choices (A, B, C, etc). This can be done with a combo box limited to a list, perhaps accounting for the condition where a grade has not yet been entered. For the OnLoad event, you can then test the grade and display the appropriate message. You can do that with an IIF.

I think I'd address the present/absent issue in a separate field so that it doesn't complicate the grade evaluation.
 

Users who are viewing this thread

Back
Top Bottom