Update query using IIF and wildcard (1 Viewer)

bionicman

Registered User.
Local time
Today, 01:15
Joined
Jul 22, 2003
Messages
145
Hello,
I am not sure if this is possible, but I am running an update query to add text in a field if a certain criteria is met. However, if the field I am adding to already contains what I am trying to add, i don't want it to add it again. Everything works fine except the IIF statement in my update field. Here is what I have:

Code:
IIf(Temp_Vendor_Trips.[Reco Classification]="*" & "V3" & "*",Temp_Vendor_Trips.[Reco Classification],Temp_Vendor_Trips.[Reco Classification] & " " & "V3")

If the field contains the text V3, I want it to be left alone and continue to show what is already in the field, if not, i want it to add V3 to the end.

Thanks in advance for the help!
 

Jon K

Registered User.
Local time
Today, 07:15
Joined
May 22, 2002
Messages
2,209
Wildcard characters need the LIKE operator.

IIf(Temp_Vendor_Trips.[Reco Classification] LIKE "*" & "V3" & "*", Temp_Vendor_Trips.[Reco Classification], Temp_Vendor_Trips.[Reco Classification] & " " & "V3")


Alternatively, instead of using IIf, you can use a Where clause in the SQL statement (or the Criteria row in query Design View) to filter the records:-

Update ..........
WHERE Temp_Vendor_Trips.[Reco Classification] NOT LIKE "*" & "V3" & "*"
.
 
Last edited:

Users who are viewing this thread

Top Bottom