Multiple Updates on one query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Currently I run two update queries one does this
***************
update sheet1 SET Sheet1.[EPIC#] = "00" & "????"
WHERE (((Sheet1.[EPIC#]) Like "????"));
*****************************
the other
*****************
update sheet1 SET Sheet1.[EPIC#] = "0" & "?????"
WHERE (((Sheet1.[EPIC#]) Like "?????"));
*********************
How can I combine them into one update query?
thanks,
RogueIT
 
Currently I run two update queries one does this
***************
update sheet1 SET Sheet1.[EPIC#] = "00" & "????"
WHERE (((Sheet1.[EPIC#]) Like "????"));
*****************************
the other
*****************
update sheet1 SET Sheet1.[EPIC#] = "0" & "?????"
WHERE (((Sheet1.[EPIC#]) Like "?????"));
*********************
How can I combine them into one update query?
thanks,
RogueIT

Are those supposed to be literal ????'s? or Wildcards?
How about an example of your data, and what you want the result to be
like after updating?
How about the field's datatype?

Here's a generic sample code:

Update YourTable set YourTable.[FieldName] =
IIf([FieldName]=CriteriaA,"ResultA",IIf([FieldName] =
CriteriaB,"ResultB","Neither A nor B"));

If it's simply a matter of adding leading zero's to the field (Text
datatype) you can use
Update YourTable Set YourTable = Format([YourTable],"000000")
 
Perhaps with the following.

UPDATE sheet1
SET Sheet1.[EPIC#] = IIF(Len([Epic#])=4,"00" & "????","0" & "?????")
WHERE (((Sheet1.[EPIC#]) Like "????"))
Or (((Sheet1.[EPIC#]) Like "?????"))

WARNING: This is not undoable. Make a backup first.
 
Back
Top