Same concept as If Statement.

G

Guest

I have a post on the 4/8/05 with this same title and it starts my problem.
someone gave me some advice but it tell me "The expression you've entered
contains invalid syntax. you may have entered a comma with out a preceding
value or identifier."
I don't understand what's wrong with my expression. This is my expression:
=IIF(Is Null([txthiredate]), "TEMP EMPLOYEE",
DateDiff("yyyy",[txthiredate],[txtdateofinjury])+(Format([txthiredate],"mmdd")>Format([txtdateofinjury],"mmdd"))

txthiredate = date of hire for an employee
txtdateofinjury = date the employee was injured

If someone can tell me what I've done wrong I would appreciate that very
much. Thank you in Advance.

Travis
 
G

Graham R Seach

You appear to have left off a closing bracket at the end.

=IIF(IsNull([txthiredate]), "TEMP EMPLOYEE", DateDiff("yyyy", [txthiredate],
[txtdateofinjury]) + (Format([txthiredate], "mmdd") >
Format([txtdateofinjury], "mmdd")))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

I tried that correction and worked at first, but only for a new entry. And as
soon as I enter an employee in the the form, even with a blank hire date, the
"TEMP EMPLOYEE" display disappears.....And it doesn't update any of my old
entries. What could this be? Thanks in advance.

Travis

Graham R Seach said:
You appear to have left off a closing bracket at the end.

=IIF(IsNull([txthiredate]), "TEMP EMPLOYEE", DateDiff("yyyy", [txthiredate],
[txtdateofinjury]) + (Format([txthiredate], "mmdd") >
Format([txtdateofinjury], "mmdd")))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Dahlman said:
I have a post on the 4/8/05 with this same title and it starts my problem.
someone gave me some advice but it tell me "The expression you've entered
contains invalid syntax. you may have entered a comma with out a preceding
value or identifier."
I don't understand what's wrong with my expression. This is my expression:
=IIF(Is Null([txthiredate]), "TEMP EMPLOYEE",
DateDiff("yyyy",[txthiredate],[txtdateofinjury])+(Format([txthiredate],"mmdd")>Format([txtdateofinjury],"mmdd"))

txthiredate = date of hire for an employee
txtdateofinjury = date the employee was injured

If someone can tell me what I've done wrong I would appreciate that very
much. Thank you in Advance.

Travis
 
G

Guest

Once I enter in an employee the "TEMP EMPLOYEE" disappears until I enter in
the Date of Injury in which case if there is no hire date I get "error#"
displayed in my years of service text box.


Graham R Seach said:
You appear to have left off a closing bracket at the end.

=IIF(IsNull([txthiredate]), "TEMP EMPLOYEE", DateDiff("yyyy", [txthiredate],
[txtdateofinjury]) + (Format([txthiredate], "mmdd") >
Format([txtdateofinjury], "mmdd")))

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

Dahlman said:
I have a post on the 4/8/05 with this same title and it starts my problem.
someone gave me some advice but it tell me "The expression you've entered
contains invalid syntax. you may have entered a comma with out a preceding
value or identifier."
I don't understand what's wrong with my expression. This is my expression:
=IIF(Is Null([txthiredate]), "TEMP EMPLOYEE",
DateDiff("yyyy",[txthiredate],[txtdateofinjury])+(Format([txthiredate],"mmdd")>Format([txtdateofinjury],"mmdd"))

txthiredate = date of hire for an employee
txtdateofinjury = date the employee was injured

If someone can tell me what I've done wrong I would appreciate that very
much. Thank you in Advance.

Travis
 
D

Dirk Goldgar

Dahlman said:
I have a post on the 4/8/05 with this same title and it starts my
problem. someone gave me some advice but it tell me "The expression
you've entered contains invalid syntax. you may have entered a comma
with out a preceding value or identifier."
I don't understand what's wrong with my expression. This is my
expression: =IIF(Is Null([txthiredate]), "TEMP EMPLOYEE",
DateDiff("yyyy",[txthiredate],[txtdateofinjury])+(Format([txthiredate],"
mmdd")>Format([txtdateofinjury],"mmdd"))

txthiredate = date of hire for an employee
txtdateofinjury = date the employee was injured

If someone can tell me what I've done wrong I would appreciate that
very much. Thank you in Advance.

Travis

You didn't want to use the actual function and expression I posted for
you?
 
D

Dirk Goldgar

Dahlman said:
Once I enter in an employee the "TEMP EMPLOYEE" disappears until I
enter in the Date of Injury in which case if there is no hire date I
get "error#" displayed in my years of service text box.

Is [txtHireDate] bound to a Date/Time field? If it's bound to a text
field, it may have a Default Value that is a zero-length string, which
is not the same as Null. You should be using date/time fields to hold
dates, not text fields. Also, your formula is probably going to give an
error if [txtdateofinjury] is Null or a zero-length string. If you're
going to use a formula like that, you'll need to test in your IIf()
condition whether either of those fields is Null.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top