Should be easy If...Else If

daniela

New member
Local time
Yesterday, 22:57
Joined
Dec 14, 2005
Messages
9
Hi, I have a form in which I want to simplify data entry. Depending on what is entered in the subject text box I would like the MT code to be entered automatically. This is the code I am trying to use. Thanks I'm new : )

I know there is a problem with the or but I don't know how else to write this statement and I have a long list of Subjects for each MT Code. Should I use a Case statement?

Private Sub Master_Tutor_Code_GotFocus()
If Subject = "IS" Or "MATH" Then
Master_Tutor_Code = "A"
ElseIF Subject = "CHEM" or "BIO" or "PHY" Then
Master_Tutor_Code = "B"


End If


End Sub
 
daniela said:
Hi, I have a form in which I want to simplify data entry. Depending on what is entered in the subject text box I would like the MT code to be entered automatically. This is the code I am trying to use. Thanks I'm new : )

I know there is a problem with the or but I don't know how else to write this statement and I have a long list of Subjects for each MT Code. Should I use a Case statement?

Try This,

Code:
Private Sub Master_Tutor_Code_GotFocus()
If Subject = "IS" Or Subject =  "MATH" Then
Master_Tutor_Code = "A"
ElseIF Subject = "CHEM" or Subject = "BIO" or Subject = "PHY" Then
Master_Tutor_Code = "B"
 
Last edited:
Selena

perfect!

Thanks, D
 
2 thoughts in addition to selena's correct answer. If there's a "Subject" table, you could add a field in it for Master_Tutor_Code, and just look up the code appropriate to the subject. If that's not feasible, and there are a lot of these, you might consider Select/Case instead of If/Then.
 

Users who are viewing this thread

Back
Top Bottom