View Single Post
  #4  
Old August 11th, 2004, 07:28 AM
Ernie
external usenet poster
 
Posts: n/a
Default How to phrase If/Then clauses in the control source field

What Tina posted belongs in VBA code. If you really prefer
to put this into your qbe pane then you would type
something like this:

NewYear: iif(left(codefield,1) = "0", 2000, iif(left
(codefield,1) = "1", 2001, iif( etc...

Note that "Year" is reserved in access, substitute
whatever field you want to store the year in where I
have "NewYear"

HTH
-----Original Message-----
I tried it but it gave me a syntax error message. Is
there a general if/then template?
-----Original Message-----
Dim intYear As Integer
intYear = Left(CodeString, 1)
Select Case intYear
Case 6 To 9
FieldOrVariable = 1990 + intYear
Case 0 To 5
FieldOrVariable = 2000 + intYear
End Select

you'll have to tweak it to work in your specific

circumstances, but that
should get you started.

hth


wrote in message
...
Hello,
This is a continuation of an earlier thread

about
Parsing strings from one field into many. I making a
database,that contains five fields of overlap and to

make
the data entry easier I am trying to automate some of

it.
I have a code field, and then four other fields whose
information can be derived from the code ((codelooks

like
this: 01MP, and has four parts. The first number refers
to the year 2000, the second number refers the season

of
the year (spring), the third to type of media (a
magazine), and the fourth the genre (politics).))

Anyway,
my problem lies in the fact that the code only has one
digit for the year, and the time span is from 1996 to
present. so how could one phrase an expression that
essentially says: if the first digit of the code string
is =6 but =9, add the value to 1990, and if the value
is =0 but =5 add it to 2000 (a short term solution;

the
code thing will eventually be revised). Thanks for any
help or info you can provide!



.

.