Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2007

Tip: Looking for answers? Try searching our database.

Updating multiple fields in one table via Update query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffro - 04 Jun 2007 18:48 GMT
Hi,
Have a table designed as follows

equip1          text
equip2          text
equip3          text
equip4          text
equip5          text
equip6          text
equip7          text
equip8          text
equip9          text
equip10          text

What I need to do is to check each field and if the field is =
"Tennessee" then
update it to read "TN"

Is there a way to do this in one update query vs having to write 10
different update queries?

Thanks
Rick Brandt - 04 Jun 2007 18:56 GMT
> Hi,
> Have a table designed as follows
[quoted text clipped - 18 lines]
>
> Thanks

UPDATE TableName
SET equip1 = IIf(equip1 = "Tennessee", "TN", equip1),
equip2 = IIf(equip2 = "Tennessee", "TN", equip2),
equip3 = IIf(equip3 = "Tennessee", "TN", equip3),
equip4 = IIf(equip4 = "Tennessee", "TN", equip4),
etc..

Essentially you are upating all of the fields all of the time, but when they
are not equal to "Tennessee" then you are setting them equal to themselves.

Signature

Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt   at   Hunter   dot   com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.