Update Query using the IIf function.

P

professor

Greetings! I am trying to create an update query tha
uses the IIf function to give staff members hired before 7/1/96
salary increase of 7%, and all others an increase of 3%. This i
from a Stellar Publications workbook that I am using as a
instructional tool (software and text duly site licensed)

My query includes the fields [Name], [HireDate], [HourlyRate].

I am using the following to create a new field indicating th
resulting HourlyRate

Raise: IIf([HireDate]<7/1/96,[HourlyRate]*1.07,1.03

[i:dbecd34e72]I have tried adding the [HourlyRate]field in front o
the *1.03, as well as a few other permutations

The essential problem is that the query always returns the secon
increase value (3% raise), as if it is not recognizing my date forma
or something. When I switch the *1.03 and *1.07 around, for instance
everyone gets the 7% raise. If I remove the date entirely, the secon
value is applied

So, what am I missing? Something[/i:dbecd34e72] BASIC
[i:dbecd34e72]right

Thanks for your help in Advance

Tyler[/i:dbecd34e72
 
D

Douglas J. Steele

Dates need to be delimited with # characters, and yes, you need HourlyRate
in both places:

Raise: IIf([HireDate]<#7/1/96#, [HourlyRate]*1.07, [HourlyRate]*1.03)
 
F

fredg

Greetings! I am trying to create an update query that
uses the IIf function to give staff members hired before 7/1/96 a
salary increase of 7%, and all others an increase of 3%. This is
from a Stellar Publications workbook that I am using as an
instructional tool (software and text duly site licensed).

My query includes the fields [Name], [HireDate], [HourlyRate].

I am using the following to create a new field indicating the
resulting HourlyRate:

Raise: IIf([HireDate]<7/1/96,[HourlyRate]*1.07,1.03)

[i:dbecd34e72]I have tried adding the [HourlyRate]field in front of
the *1.03, as well as a few other permutations.

The essential problem is that the query always returns the second
increase value (3% raise), as if it is not recognizing my date format
or something. When I switch the *1.03 and *1.07 around, for instance,
everyone gets the 7% raise. If I remove the date entirely, the second
value is applied.

So, what am I missing? Something[/i:dbecd34e72] BASIC,
[i:dbecd34e72]right?

Thanks for your help in Advance!

Tyler[/i:dbecd34e72]

Doug Steele answered your how-to question.

In addition, I would like to call your attention to your use of the
word "Name" as a field name.
Name is a reserved Access/VBA/Jet word and should not be used as a
field name.
See the Microsoft KnowledgeBase article for your version of Access:

109312 'Reserved Words in Microsoft Access' for Access 97
209187 'ACC2000: Reserved Words in Microsoft Access'
286335 'ACC2002: Reserved Words in Microsoft Access'
321266 'ACC2002: Microsoft Jet 4.0 Reserved Words'
 

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