using an IIF with a field value to update

  • Thread starter Thread starter Jon M.
  • Start date Start date
J

Jon M.

Hello all, I am running, or at least trying to run an update query using an
iif statements. I have a field called LicType, which can either be "2 Year"
or "4 year". I have another field called CreditsNeeded which is a number
field. If LicType = 2 Year, I want CreditsNeeded to equal 24. If LicType =
4 Year, I want CreditsNeeded to equal 48. Here is what I tried but when I run
the query it updates my CreditsNeeded to 0.

IIf([LicenseType]="4 Year",[CreditsNeeded]=48,[CreditsNeeded]=24)

As always I appreciate any suggestions.
 
If CreditsNeeded is a text field then use this --
IIf([LicenseType]="4 Year",[CreditsNeeded]="48",[CreditsNeeded]="24")
 
Your update SQL should look partially like:
SET CreditsNeeded = IIf([LicenseType]="4 Year",48,24)

I would question why you need to store a value that can be calculated.
 
Thank you so much!
--
Jon M.


Duane Hookom said:
Your update SQL should look partially like:
SET CreditsNeeded = IIf([LicenseType]="4 Year",48,24)

I would question why you need to store a value that can be calculated.

--
Duane Hookom
Microsoft Access MVP


Jon M. said:
Hello all, I am running, or at least trying to run an update query using an
iif statements. I have a field called LicType, which can either be "2 Year"
or "4 year". I have another field called CreditsNeeded which is a number
field. If LicType = 2 Year, I want CreditsNeeded to equal 24. If LicType =
4 Year, I want CreditsNeeded to equal 48. Here is what I tried but when I run
the query it updates my CreditsNeeded to 0.

IIf([LicenseType]="4 Year",[CreditsNeeded]=48,[CreditsNeeded]=24)

As always I appreciate any suggestions.
 
Back
Top