If Or Then Question!

Talismanic

Registered User.
Local time
Today, 19:41
Joined
May 25, 2000
Messages
377
I am using an If Or Then like this:

If TimeClass = "TR" Or Me!TimeClass = "FT" Then

There is code that follows the If Then that I am not having any problems with. The problem is that I need a way to set an earnings code based on the If Then.

If TimeClass is TR the EarnCode should = 9, if it is FT the EarnCode would be 10.

Should I put a nested If Then after the first or is the a better way to do it?

Any ideas?

[This message has been edited by Talismanic (edited 11-10-2000).]
 
You could use a simple If Then Else statement.

If Timeclass = "TR" Then
Earncode=9
else

If Timeclass = "FT" Then
Earcode=10
Else
'Not a valid time Class

EndIF
EndIF
 
BarkerD, I edited my question at the same time you were answering it. I added this to the end.

Should I put a nested If Then after the first or is the a better way to do it?

I think you answered the question (it requires another If Then) but are there any problems associated with If Thens inside of If Thens?
 
You could also use a Case Select statement to do this, it's a lot cleaner and easier to add additional choices:

Select Case Me!TimeClass
Case "TR"
EarnCode = 9
Case Else
EarnCode = 10
End Select

HTH
RDH
 
If you need an extensible list of timeclass possibilites, each with it's own earncode, you might be better off storing the pairs of values in a table and using Dlookup to find the appropriate one.

HTH

Mike
 
It sounds like the select case is the way for me to go. How do I work it in this code.

Code:
If TimeClass = "TR" Or Me!TimeClass = "FT" Then

With CodeContextObject
    .JobNumber.DefaultValue = """" & .JobNumber & """"
    .JobName.DefaultValue = """" & .JobName & """"
    .WeekEnding.DefaultValue = """" & .WeekEnding & """"
    .EntryPerson.DefaultValue = """" & .EntryPerson & """"
    .EmployeeNumber.DefaultValue = """" & .EmployeeNumber & """"
    .LastName.DefaultValue = """" & .LastName & """"
    .FirstName.DefaultValue = """" & .FirstName & """"
    .Travel.DefaultValue = """" & .Travel & """"
End With

DoCmd.GoToControl "JobNumber"
DoCmd.GoToRecord acForm, "TimeSheetGR", acNewRec

DoCmd.openform "frmTravel", acNormal, , , acAdd, acNormal
 
    Forms!frmTravel![EmployeeNumber] = Me![EmployeeNumber]
    Forms!frmTravel![JobDate] = Me![WeekEnding]
    Forms!frmTravel![JobNumber] = Me![JobNumber]
    Forms!frmTravel!PC.SetFocus
    
End If
 

Users who are viewing this thread

Back
Top Bottom