Hi, I have a quick question.
I am trying to calculate the age of a person. Once I have a age I have to set it to appropriate Type. For example if age is less then 18, then the type would be "Child", if the age is less then 65, the type would be "Adult, and so on.
This is the code snippet that I have so far:
InputDate := TODAY;
Year := DATE2DMY(InputDate,3);
BirthDate := Customer.Birthdate;
BirthDay := DATE2DMY (BirthDate, 3);
IF (Customer.Birthdate = 0D) THEN
BEGIN
Job."Primary Consumer Type" :='';
END;
PrimaryType := (Year - BirthDay);
CASE PrimaryType OF
1..17:
BEGIN
Job."Primary Consumer Type" := 'Child';
END;
18..64:
BEGIN
Job."Primary Consumer Type" :='Adult';
END;
ELSE
BEGIN
Job."Primary Consumer Type" := 'Senior';
END;
END;
The error Message I get on this line (Job."Primary Consumer Type" :='';) is: Type conversion is not possible because 1 of the operators contains an invalid type. Option := Text
Primary Consumer Type is an Option field with the following options child, senior, adult, etc
I know the reason of the error, I just dont know how to fix it.
0
Comments
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"Child";
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";
etc...
"A Variable was expected. For example:
MyVar
Customer.Name"
Thanks.
Just for knowledge sake, what does putting the code like this (Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";) actually achieve. Just in case I have similar issue some other time, I want to be able to know how to fix it myself.
BirthDay := DATE2DMY (BirthDate, 3);
shouldn't BirthDay actually be named BirthYear
http://www.BiloBeauty.com
http://www.autismspeaks.org
Job."Primary Consumer Type" := 0;
is the same as
Job."Primary Consumer Type" := Job."Primary Consumer Type"::"";
This is much easier to understand: option type = option type:: (of) blank.
I really appericate it.