if..end if problem..Urgent help please

  • Thread starter Thread starter bob
  • Start date Start date
B

bob

I am writing this code for this program which does
reimburses employees per their grades...I am using this
code....MY problem..it seems to work fine for the 2004
year but for the class start dates before 2004 like
08/08/2003..it does not work right. Where Am i Making the
mistake. below is the code I am using.


If Me![Class Start Date] > "01/01/2004" Then

If Me![Final Grade] = "B" Then
Percent = "90%"

Else

If Me![Final Grade] = "A" Then
Percent = "70%"

End if
 
I am writing this code for this program which does
reimburses employees per their grades...I am using this
code....MY problem..it seems to work fine for the 2004
year but for the class start dates before 2004 like
08/08/2003..it does not work right. Where Am i Making the
mistake. below is the code I am using.


If Me![Class Start Date] > "01/01/2004" Then

If Me![Final Grade] = "B" Then
Percent = "90%"

Else

If Me![Final Grade] = "A" Then
Percent = "70%"

End if

From what I see you have everything as text values. Assuming you are
using a date datatype for [Class Start Date] then it should be:
If Me![Class Start Date] > #01/01/2004# Then

And the percentages should be 0.9 , etc. How data is presented
(formatted) VS how it is stored and processed are different things.

I'm a little concerned about your datastructure.

- Jim
 
bob said:
I am writing this code for this program which does
reimburses employees per their grades...I am using this
code....MY problem..it seems to work fine for the 2004
year but for the class start dates before 2004 like
08/08/2003..it does not work right. Where Am i Making the
mistake. below is the code I am using.


If Me![Class Start Date] > "01/01/2004" Then

If Me![Final Grade] = "B" Then
Percent = "90%"

Else

If Me![Final Grade] = "A" Then
Percent = "70%"

End if

Among other things, I see three "block If" statements and only one End
If. Also, assuming that [Class Start Date] is a date/time value, you
should use a date literal to compare it to, not a string. Try this:

If Me![Class Start Date] > #01/01/2004# Then
If Me![Final Grade] = "B" Then
Percent = "90%"
End If
Else
If Me![Final Grade] = "A" Then
Percent = "70%"
End If
End if

Note that the logic you provided doesn't say anything about what Percent
should be in other possible cases.
 
Back
Top